Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/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++)
    {
    QStandardItem
    item = new QStandardItem(QString::number(i));

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

    Screens:

    Qt4 root:
    !http://s4.postimg.org/css9cp2e5/Qt4_root.png(Qt4 ROOT)!
    Qt4:
    !http://s7.postimg.org/7972kpahn/Qt4.png(Qt4)!
    Qt5 root:
    !http://s28.postimg.org/w3ibvqe3h/Qt5_root.png(Qt5 ROOT)!
    Qt5:
    !http://s29.postimg.org/ilwkamu93/Qt5.png(Qt5)!



  • 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