Application created in Qt Creator uses combo check boxes. ComboCheckBox has uncheckable title item and checkable items:
-- Choose position
[ ] option1
[ ] option2
...
It is constructed by the following approach:
// Model construction.
model.insertRow(0, title);
for (int i = 1; i < injuries.length(); i++)
{
item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
item->setData(Qt::Unchecked, Qt::CheckStateRole);
model.insertRow(i, item);
}
// Setting model for combo chech box.
comboCheckBox->setModel(&model);
// Model construction.
QStandardItem* title = new QStandardItem(injuries.at(0));
model.insertRow(0, title);
for (int i = 1; i < injuries.length(); i++)
{
QStandardItem* item = new QStandardItem(injuries.at(i));
item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
item->setData(Qt::Unchecked, Qt::CheckStateRole);
model.insertRow(i, item);
}
// Setting model for combo chech box.
comboCheckBox->setModel(&model);
To copy to clipboard, switch view to plain text mode
I'm trying to map data from SQLite to this combo check box by this way:
mapper->setModel(model);
mapper->addMapping(comboCheckBox, model->fieldIndex("inj1"), "currentIndex");
mapper = new QDataWidgetMapper(this);
mapper->setModel(model);
mapper->setItemDelegate(new QSqlRelationalDelegate(this));
mapper->addMapping(comboCheckBox, model->fieldIndex("inj1"), "currentIndex");
To copy to clipboard, switch view to plain text mode
But to no avail. The same mapper works fine with usual check boxes:
mapper->addMapping(checkBox, model->fieldIndex("inj1"), "currentIndex");
mapper->addMapping(checkBox, model->fieldIndex("inj1"), "currentIndex");
To copy to clipboard, switch view to plain text mode
Is any way to map checkable flags from so kind of combo check box to the row of smth of the SQLite data base?
I have failed to map even the current index not to mention separate checkable fields. Your elegant solutions would be just by the way for not very fancy combo check box.
Bookmarks