[Development] qsizetype and classes working with QStrings or QList

Lars Knoll lars.knoll at qt.io
Wed Aug 26 08:36:27 CEST 2020


Going back to the original question here:

> On 23 Aug 2020, at 16:06, Marcel Krems <marcel.k.dev at gmail.com> wrote:
> 
> Hi,
> 
> 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

I don’t think we should port these to use qsizetype.

> * QRegularExpression (match offset)
> * QStringMatcher
> * QSyntaxHighlighter
> * QTextBoundaryFinder
> * QXmlString::size

I think we should still fix these, as they are in low level string processing classes

> QtGui:
> * QTextCursor
> * QTextDocument (find offset, character{At,Count})
> * QTextLayout
> * QValidator and subclasses (validate offset)

These here are questionable. Editing a text file with more than 2G characters? Sounds unlikely.
> 
> QtWidgets:
> * QAbstractItemView and subclasses
> * QLineEdit

Neither should we touch these IMO.

Cheers,
Lars



More information about the Development mailing list