29 QList < QPair<Qt::BrushStyle, QString> > styles;
30 styles << qMakePair( Qt::SolidPattern, tr(
"Solid" ) )
31 << qMakePair( Qt::NoBrush, tr(
"No Brush" ) )
32 << qMakePair( Qt::HorPattern, tr(
"Horizontal" ) )
33 << qMakePair( Qt::VerPattern, tr(
"Vertical" ) )
34 << qMakePair( Qt::CrossPattern, tr(
"Cross" ) )
35 << qMakePair( Qt::BDiagPattern, tr(
"BDiagonal" ) )
36 << qMakePair( Qt::FDiagPattern, tr(
"FDiagonal" ) )
37 << qMakePair( Qt::DiagCrossPattern, tr(
"Diagonal X" ) )
38 << qMakePair( Qt::Dense1Pattern, tr(
"Dense 1" ) )
39 << qMakePair( Qt::Dense2Pattern, tr(
"Dense 2" ) )
40 << qMakePair( Qt::Dense3Pattern, tr(
"Dense 3" ) )
41 << qMakePair( Qt::Dense4Pattern, tr(
"Dense 4" ) )
42 << qMakePair( Qt::Dense5Pattern, tr(
"Dense 5" ) )
43 << qMakePair( Qt::Dense6Pattern, tr(
"Dense 6" ) )
44 << qMakePair( Qt::Dense7Pattern, tr(
"Dense 7" ) );
47 setIconSize( QSize( iconSize * 2, iconSize ) );
49 for (
int i = 0; i < styles.count(); i++ )
51 Qt::BrushStyle style = styles.at( i ).first;
52 QString name = styles.at( i ).second;
53 addItem(
iconForBrush( style ), name, QVariant( static_cast<int>( style ) ) );
63 return ( Qt::BrushStyle ) currentData().toInt();
68 int idx = findData( QVariant( static_cast<int>( style ) ) );
69 setCurrentIndex( idx == -1 ? 0 : idx );
74 QPixmap pix( iconSize() );
76 pix.fill( Qt::transparent );
79 QBrush brush( QColor( 100, 100, 100 ), style );
81 QPen pen( Qt::NoPen );
83 p.drawRect( QRect( QPoint( 0, 0 ), iconSize() ) );
int scaleIconSize(int standardSize)
Scales an icon size to compensate for display pixel density, making the icon size hi-dpi friendly...
void setBrushStyle(Qt::BrushStyle style)
QIcon iconForBrush(Qt::BrushStyle style)
Qt::BrushStyle brushStyle() const
QgsBrushStyleComboBox(QWidget *parent=nullptr)