From 202acb9dc777eefd455805592fa4ac6b9968a08b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 10 Sep 2024 16:22:20 -0700 Subject: [PATCH] QCommonStyle: work around apparent MSVC bug in using QFlag With the upcoming change to QFlags to support 64-bit, MSVC started to complain that it can't convert from Qt::Alignment to QFlag and back to Qt::Alignment. It is correct that this path has an explicit and shouldn't be taken, but a) it's worked for years b) GCC and Clang insert an extra conversion to int (I guess) In any case, header->iconAlignment is already a Qt::Alignment so we don't need to go through QFlag here. qcommonstyle.cpp(1666): error C2440: '': cannot convert from 'const Qt::Alignment' to 'QFlag' qcommonstyle.cpp(1666): note: Constructor for class 'QFlag' is declared 'explicit' Change-Id: If349995b779be9e3dab4fffd8701af8615ae407b Reviewed-by: Christian Ehrlicher Reviewed-by: Volker Hilsheimer (cherry picked from commit dc1f4b742edf469a61eb6067a5a0ca44aac6cd48) Reviewed-by: Qt Cherry-pick Bot --- src/widgets/styles/qcommonstyle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index aab1192d500..af163669a08 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -1668,7 +1668,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, = header->icon.pixmap(QSize(iconExtent, iconExtent), p->device()->devicePixelRatio(), (header->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); int pixw = pixmap.width() / pixmap.devicePixelRatio(); - QRect aligned = alignedRect(header->direction, QFlag(header->iconAlignment), pixmap.size() / pixmap.devicePixelRatio(), rect); + QRect aligned = alignedRect(header->direction, header->iconAlignment, pixmap.size() / pixmap.devicePixelRatio(), rect); QRect inter = aligned.intersected(rect); p->drawPixmap(inter.x(), inter.y(), pixmap, inter.x() - aligned.x(), inter.y() - aligned.y(),