3

i want to make a line pattern combo box in Qt same as it is shown in the picture , please tell me is it possible to make a combo box in Qt like shown in the picture. Any help would be appreciated

Regards

enter image description here

1 Answers1

2

Easy way:

comboBox->setIconSize(QSize(100, 24));
comboBox->addItem(lineIcon, "");
comboBox->addItem(dotLineIcon, "");
comboBox->addItem(dashLineIcon, "");
...

Correct way:

comboBox->setItemDelegate(...);
Amartel
  • 4,248
  • 2
  • 15
  • 21
  • i have used the easy way and generated icon with pixmp now combobox is showing the line pattern but the problem is that it generate icon with a constant width , i want to to increase the size of icon but no success – Akmal Naqvi Jun 17 '15 at 06:09
  • The only way, that comes to my mind, is to inherit `QComboBox` and override `resizeEvent`. – Amartel Jun 17 '15 at 06:50
  • Or install event filter. – Amartel Jun 17 '15 at 09:13