26 connect(
this,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [ = ]
35 mAlignments = alignments;
41 return static_cast< Qt::Alignment
>( currentData().toInt() );
46 const int index = findData( QVariant( alignment ) );
48 setCurrentIndex( index );
53 const int index = findData( QVariant( alignment ) );
56 if ( !text.isEmpty() )
57 setItemText( index, text );
59 setItemIcon( index, icon );
63 void QgsAlignmentComboBox::populate()
70 if ( mAlignments & Qt::AlignLeft )
72 if ( mAlignments & Qt::AlignHCenter )
74 if ( mAlignments & Qt::AlignRight )
76 if ( mAlignments & Qt::AlignJustify )
79 const int index = findData( QVariant( prevAlign ) );
81 setCurrentIndex( index );
83 mBlockChanged =
false;
void customizeAlignmentDisplay(Qt::Alignment alignment, const QString &text=QString(), const QIcon &icon=QIcon())
Sets the text and icon to use for a particular alignment option, replacing the default text or icon...
QgsAlignmentComboBox(QWidget *parent=nullptr)
Constructor for QgsAlignmentComboBox, with the specified parent widget.
void setAvailableAlignments(Qt::Alignment alignments)
Sets the available alignment choices shown in the combo box.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
void setCurrentAlignment(Qt::Alignment alignment)
Sets the current alignment choice.
void changed()
Emitted when the alignment is changed.
Qt::Alignment currentAlignment() const
Returns the current alignment choice.