Important: Please read the Qt Code of Conduct -

Combobox with checkboxes problem with Qt4 and Qt5 difference.

  • Hi,

    I am tried to create combobox with checkboxes but I got a problem and dont know how to solve it.
    I have a code which create combobox with checkboxes but it only works on Qt4 and only when i run a program on root. But now I need to use the same code in Qt5 and I cant see any checkboxes, dont know why. I think the problem is connected to OS I use but not sure. I am using Ubuntu 12.04 with unity.

    Code and screens below:
    @ QStandardItemModel model = new QStandardItemModel(3, 1); // 3 rows, 1 col
    for(int i=0;i<3;i++)
    item = new QStandardItem(QString::number(i));

        item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
        item->setData(Qt::Unchecked, Qt::CheckStateRole);
        model->setItem(i, 0, item);


    Qt4 root:
    ! ROOT)!
    Qt5 root:
    ! ROOT)!

  • I've found that this works as expected with plastique and motif and cleanlooks styles, but not gtk. Using Ubuntu 13.10.

  • Ok, thanks I will check it tomorrow.

  • I can see it works when I run my applicatino from command line:
    @./app -style plastique@
    but the problem is in Qt5 motif, cleanooks and plastique styles are removed and you cant use it from the code. There is fusion style instead but this style also doesnt show checkboxes in combobox.

Log in to reply