stanislavf
23rd September 2016, 21:20
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.
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);
I'm trying to map data from SQLite to this combo check box by this way:
mapper = new QDataWidgetMapper(this);
mapper->setModel(model);
mapper->setItemDelegate(new QSqlRelationalDelegate(this));
mapper->addMapping(comboCheckBox, model->fieldIndex("inj1"), "currentIndex");
But to no avail. The same mapper works fine with usual check boxes:
mapper->addMapping(checkBox, model->fieldIndex("inj1"), "currentIndex");
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.
-- Choose position
[ ] option1
[ ] option2
...
It is constructed by the following approach:
// 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);
I'm trying to map data from SQLite to this combo check box by this way:
mapper = new QDataWidgetMapper(this);
mapper->setModel(model);
mapper->setItemDelegate(new QSqlRelationalDelegate(this));
mapper->addMapping(comboCheckBox, model->fieldIndex("inj1"), "currentIndex");
But to no avail. The same mapper works fine with usual check boxes:
mapper->addMapping(checkBox, model->fieldIndex("inj1"), "currentIndex");
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.