I'm trying to set a QComboBox
to have expanding height, but adjusting to contents length.
The combo is created like this:
self.dataentrycombo = QComboBox()
self.dataentrycombo.setIconSize(QSize(48,48))
self.dataentrycombo.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
self.dataentrycombo.setSizeAdjustPolicy(QComboBox.AdjustToContents)
self.dataentrycombo.setModel(self.dataentrymodel)
After I populate my model, the size adjusts, but the height is smaller than the toolbar that the combobox lives in:
If I change my main window size then it will expand fully:
I have tried using QComboBox.AdjustToMinimumContentsLengthWithIcon
, but then it just looks like this:
My model items are created like this:
item = QStandardItem(QIcon(form.icon), form.icontext)
item.setData(form, Qt.UserRole + 1)
self.dataentrymodel.appendRow(item)
Extra Info:
- Qt: 4.7
- Windows 7 and 8
I was able to fix it using:
It's a bit of a dirty hack but it works OK for now.