21 #include <QApplication>
27 int textMinWidth = fontMetrics().boundingRect( mText ).width();
28 mTextHeight = fontMetrics().height();
29 #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
34 mMinWidth = 2 * mLabelMargin + textMinWidth;
35 setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
41 return QSize( mMinWidth, mTextHeight + mLabelMargin );
46 return QSize( mMinWidth, mTextHeight + mLabelMargin );
51 QPainter painter(
this );
52 QPalette
pal = QPalette( qApp->palette() );
53 QColor headerBgColor =
pal.color( QPalette::Mid );
54 QColor headerTextColor =
pal.color( QPalette::BrightText );
57 painter.setBrush( headerBgColor );
58 painter.setPen( Qt::NoPen );
59 painter.drawRect( QRect( 0, 0, width(), mTextHeight + mLabelMargin ) );
62 painter.setPen( headerTextColor );
63 painter.drawText( QPoint( mLabelMargin, 0.25 * mLabelMargin + mTextHeight ), mText );
68 : QWidgetAction( parent )
71 setDefaultWidget( w );