diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2022-03-21 17:28:55 +0100 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2022-05-16 09:46:27 +0200 |
commit | 53ee4c8b1f7ae72e7005166e1c0dbc4659f2ab32 (patch) | |
tree | ddf2a96d2945be8039a81beb50f723d547ff26d9 /src/widgets/itemviews/qtreewidget.cpp | |
parent | 5d8f815e101da3ae9cd6a666cc097853f52b21da (diff) |
Item widgets: clean up treatment of Qt::TextAlignmentRole / CheckStateRole
The item widgets all have an API flaw: getters and setters for the text
alignment deal with int instead of Qt::Alignment.
Deprecate the existing setters and introduce others taking
Qt::Alignment. Store the alignment directly into the item widget (now
that views know how to handle it).
We can't change the getters without cluttering the API, so make that a
Qt 7 change. Users can prepare by forcibly casting the return value to
Qt::Alignment; this is going to work in Qt 6 and 7.
While at it: streamline the handling of Qt::CheckStateRole as well,
avoiding to rely on a pointless Qt::CheckState to int conversion
through QVariant (the setter stores a Qt::CheckState, but the getter
retrieves an int and converts it to a Qt::CheckState).
Task-number: QTBUG-75172
Change-Id: I9f29e818e93cb2dc1d8e042bc320162c2f692112
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/itemviews/qtreewidget.cpp')
-rw-r--r-- | src/widgets/itemviews/qtreewidget.cpp | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index 31e075a788..5ce5c29e82 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -1362,17 +1362,44 @@ bool QTreeWidgetItem::isFirstColumnSpanned() const */ /*! + \if defined(qt7) + + \fn Qt::Alignment QTreeWidgetItem::textAlignment(int column) const + + Returns the text alignment for the label in the given \a column. + + \else + \fn int QTreeWidgetItem::textAlignment(int column) const - Returns the text alignment for the label in the given \a column - (see \l{Qt::AlignmentFlag}). + Returns the text alignment for the label in the given \a column. + + \note This function returns an int for historical reasons. It will + be corrected to return Qt::Alignment in Qt 7. + + \sa Qt::Alignment + + \endif */ /*! + \obsolete [6.4] Use the overload that takes a Qt::Alignment argument. + \fn void QTreeWidgetItem::setTextAlignment(int column, int alignment) Sets the text alignment for the label in the given \a column to - the \a alignment specified (see \l{Qt::AlignmentFlag}). + the \a alignment specified. + + \sa Qt::Alignment +*/ + +/*! + \since 6.4 + + \fn void QTreeWidgetItem::setTextAlignment(int column, Qt::Alignment alignment) + + Sets the text alignment for the label in the given \a column to + the \a alignment specified. */ /*! |