[Development] qsizetype and classes working with QStrings or QList

Иван Комиссаров abbapoh at gmail.com
Tue Aug 25 00:10:24 CEST 2020


It would be nice if QAbstractItemModel will support qsizetype instead of int, but I do not see how this is possible considering the fact that rowCount/columnCount return int. I suppose, it is not very hard to patch QModelIndex, but what to do with virtual functions? The user code will break.
The only solution I see is to add QAbstractItemModelV2 with the «wide» interface and provide a proxy for the old one.

Ivan

> 23 авг. 2020 г., в 16:06, Marcel Krems <marcel.k.dev at gmail.com> написал(а):
> 
> 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
> * 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
> 
> 
> Kind regards,
> Marcel
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> https://lists.qt-project.org/listinfo/development



More information about the Development mailing list