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: '<function-style-cast>': 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 <ch.ehrlicher@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit dc1f4b742edf469a61eb6067a5a0ca44aac6cd48)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Thiago Macieira 2024-09-10 16:22:20 -07:00 committed by Qt Cherry-pick Bot
parent 24be12c267
commit 202acb9dc7

View File

@ -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(),