I have a rather simple-looking problem that stumbled me for quite some time.
I have a QtWidgets app with a QComboBox, It's a standart combobox but with a tickmark next to a selected item. This tick mark is caused by this bit of style sheet
{
background-color: red
}
{
background-color: green
}
QComboBox
{
background-color: red
}
QComboBox:on
{
background-color: green
}
To copy to clipboard, switch view to plain text mode
If both these items are missing from the stylesheet, there is no tick, if any one - the tick mark is here.
Now I want to make the items of the combobox a bit larger. Some snoopind revealed that the most reliable way for doind so is applying a QStyledItemDelegate with its sizeHint overriden. The function looks like this
QSize CComboBoxPopupItemDelegate
::sizeHint(const QStyleOptionViewItem
&,
}
QSize CComboBoxPopupItemDelegate::sizeHint(const QStyleOptionViewItem&,
const QModelIndex &) const {
return QSize(200, 60);
}
To copy to clipboard, switch view to plain text mode
and installation went like this
language_selector_->view()->setItemDelegate(new CComboBoxPopupItemDelegate(this));
language_selector_->view()->setItemDelegate(new CComboBoxPopupItemDelegate(this));
To copy to clipboard, switch view to plain text mode
The items indeed grew to the desired size but the tick mark was gone. Also the colors were wrong - instead of red and green it's the deafult window colors
Is there a way to both increase the size of the items in the popup and keep the tickmark?
My OS in Ubuntu if it's of any relevance.
Bookmarks