Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-86224

Use qsizetype when interfacing with QStrings and QLists to avoid warnings

    XMLWordPrintable

Details

    • Task
    • Resolution: Duplicate
    • P3: Somewhat important
    • None
    • 6.0
    • None
    • 13
    • Foundation PM Prioritized

    Description

      From the corresponding mailinglist thread:

      since QString, QList, etc. are using qsizetype for indexing- and size-operations.
      What is the plan with classes working with aforementioned container classes which are still using int in their interfaces?
      If they keep using int there could be a lot of warnings like this one:
      warning: implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'int' [-Wshorten-64-to-32]
      Or you have to plaster your code with casts. E.g. every time you pass an index of your container to your model class.

      Some classes which are probably affected:
      QtCore:

      • QAbstractItemModel and subclasses (using QList or std::vector as data storage)
      • QModelIndex
      • QRegularExpression (match offset)
      • QStringMatcher
      • QSyntaxHighlighter
      • QTextBoundaryFinder
      • QXmlString::size

      QtGui:

      • QTextCursor
      • QTextDocument (find offset, character{At,Count})
      • QTextLayout
      • QValidator and subclasses (validate offset)

      QtWidgets:

      • QAbstractItemView and subclasses
      • QLineEdit

      Attachments

        For Gerrit Dashboard: QTBUG-86224
        # Subject Branch Project Status CR V

        Activity

          People

            cnn Qt Core & Network
            mkrems Marcel Krems
            Vladimir Minenko Vladimir Minenko
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes