PDA

View Full Version : Ubuntu 13.10 - cant make ComboBox with checkable items



wyder
12th March 2014, 10:15
Hello, I discovered some problem with make ComboBox with checkable items.
I have used simple code from http://stackoverflow.com/questions/8422760/combobox-of-checkboxes:



#include <QtGui>

int main(int argc, char** argv)
{
QApplication app(argc, argv);

QStandardItemModel model(3, 1); // 3 rows, 1 col
for (int r = 0; r < 3; ++r)
{
QStandardItem* item = new QStandardItem(QString("Item %0").arg(r));

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

model.setItem(r, 0, item);
}

QComboBox* combo = new QComboBox();
combo->setModel(&model);

QListView* list = new QListView();
list->setModel(&model);

QTableView* table = new QTableView();
table->setModel(&model);

QWidget container;
QVBoxLayout* containerLayout = new QVBoxLayout();
container.setLayout(containerLayout);
containerLayout->addWidget(combo);
containerLayout->addWidget(list);
containerLayout->addWidget(table);

container.show();

return app.exec();
}


Its generate sample treeview, tableview and combobox view with checkable items.
It works well under windos.

But i compiled it under ubuntu (13.10) and there is a problem wich combo box - the
items are greyed, unable to clik and without the checkbox.

Is there a possibility to make it working uner Ubuntu?

anda_skoa
12th March 2014, 12:44
I've tested this Qt4 on Linux with several styles and it work with others but cleanlooks.

You can try yourself, for example


programname -style plastique


Interestingly, if I set the list view as the combobox view


combo->setView(new QListView);

I get checkable items, but clickingan item does not close the popup.

With Qt5 I get the behavior with all styles.

Perhaps something to search the bug database for.

Cheers,
_