Skip to content

QStylePainter::drawItemPixmap, QStyle::drawItemPixmap, etc.

Ivailo Monev edited this page Nov 2, 2018 · 1 revision

This was done in https://github.com/fluxer/katie/commit/c26c91e03ade00e7448039afe54732e7f7331f26, the methods do not support any text flags (e.g. TextFlag) and the change makes it clear at compile time. Mixing enums as int/uint is discouraged unless otherwise stated in the documentation of the respective classes. Casting or constructing QFlag from the values is not a solution.

No source compatible methods are in place because you should evaluate how to handle this in your projects. For an example:

uint flags = Qt::AlignLeft | Qt::TextWordWrap;
...
drawItemPixmap(p, mbi->rect, flags, pix);
drawItemText(p, textRect, flags | Qt::TextShowMnemonic, btn->palette, btn->state & State_Enabled, btn->text, QPalette::WindowText);

Should be changed to:

Qt::Alignment pixmapflags = Qt::AlignLeft;
uint textflags = Qt::TextWordWrap;
...
drawItemPixmap(p ,mbi->rect, pixmapflags, pix);
drawItemText(p, textRect, textflags | Qt::TextShowMnemonic, btn->palette, btn->state & State_Enabled, btn->text, QPalette::WindowText);
...