From dc1f4b742edf469a61eb6067a5a0ca44aac6cd48 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' Pick-to: 6.8 Change-Id: If349995b779be9e3dab4fffd8701af8615ae407b Reviewed-by: Christian Ehrlicher Reviewed-by: Volker Hilsheimer --- 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 ed891b47069..45701078781 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -1663,7 +1663,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, = header->icon.pixmap(QSize(iconExtent, iconExtent), QStyleHelper::getDpr(p), (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(),