Thanks wysota, but it doesn't work for me when I'm trying to customize row height for combo box popup.
Actually stylesheet reference recommends to do it via "QComboBox QAbstractItemView" selector, but
"QComboBox QAbstractItemView::item" doesn't custom anything.
I suggested that ::item subcontrol is available only for concrete QAbstractItemView subclasses, not for
QAbstractItemView itself. I read qt code and found that QComboBox uses QComboBoxListView class which
is a subclass of QListView. So I tried to use "QComboBox QListView::item", but it doesn't work too.
I solved my problem with a help of this class:
class CComboBoxPopupItemDelegate : public QStyledItemDelegate
{
public:
CComboBoxPopupItemDelegate
(QObject* parent
= 0) : QStyledItemDelegate(parent)
{
}
{
return QSize(60,
100);
//enter your values here }
}
class CComboBoxPopupItemDelegate : public QStyledItemDelegate
{
public:
CComboBoxPopupItemDelegate(QObject* parent = 0)
: QStyledItemDelegate(parent)
{
}
QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const
{
return QSize(60, 100); //enter your values here
}
}
To copy to clipboard, switch view to plain text mode
In client code:
view->setItemDelegate(new CComboBoxPopupItemDelegate(this))
QAbstractItemView* view = comboBox->view();
view->setItemDelegate(new CComboBoxPopupItemDelegate(this))
To copy to clipboard, switch view to plain text mode
Alas I coudn't find easier solution.
Bookmarks