Skip to content

Commit

Permalink
Draw at least the color rectangle under the Qt 6.7.1 windows style
Browse files Browse the repository at this point in the history
  • Loading branch information
tumic0 committed May 24, 2024
1 parent 73fa197 commit 332abd5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/GUI/colorbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ void ColorBox::paintEvent(QPaintEvent *event)
QStyleOptionComboBox option;
option.initFrom(this);

// Fallback for styles that do not draw the background
painter.setBrush(_color);
painter.setPen(Qt::NoPen);
painter.drawRect(event->rect().adjusted(2, 2, -2, -2));

// If works, overpaints the previous rectangle
#if defined(Q_OS_MAC) || defined(Q_OS_WIN32)
painter.setBrush(_color);
painter.drawPrimitive(QStyle::PE_Frame, option);
#else // Q_OS_MAC || Q_OS_WIN32
// Fallback for some broken QT4 styles that do not draw the background
painter.setBrush(_color);
painter.setPen(Qt::NoPen);
painter.drawRect(event->rect().adjusted(2, 2, -2, -2));
// If works (QT5 and most QT4 styles) overpaints the previous rectangle
option.palette.setBrush(QPalette::Base, _color);
painter.drawPrimitive(QStyle::PE_PanelLineEdit, option);
painter.drawPrimitive(QStyle::PE_FrameLineEdit, option);
Expand Down

0 comments on commit 332abd5

Please sign in to comment.