leinad
13th February 2020, 19:13
Hi,
I created a group of checkboxes in a combo box. It works fine, but I would also like to click on the text next to the check box besides the check box itself to check and uncheck the box.
Any ideas how to do it. Multiselect doesn't seem to do the trick.
QList<QStandardItem *> typeCheckBoxes;
QStringList typeNames;
QStandardItemModel *typeModel;
typeNames << "ujkkl" << "alkjbs" << "djklef" << "hijkl";
for(int i = 0; i < selectedNames.size(); i++)
{
typeCheckBoxes << new QStandardItem();
typeCheckBoxes[i]->setText(typeNames[i]);
typeModel->setItem(i, 0, typeCheckBoxes[i]);
typeCheckBoxes[i]->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
typeCheckBoxes[i]->setData(Qt::Checked, Qt::CheckStateRole);
typeCheckBoxes[i]->setCheckable(true);
}
Thanks in advance.
I created a group of checkboxes in a combo box. It works fine, but I would also like to click on the text next to the check box besides the check box itself to check and uncheck the box.
Any ideas how to do it. Multiselect doesn't seem to do the trick.
QList<QStandardItem *> typeCheckBoxes;
QStringList typeNames;
QStandardItemModel *typeModel;
typeNames << "ujkkl" << "alkjbs" << "djklef" << "hijkl";
for(int i = 0; i < selectedNames.size(); i++)
{
typeCheckBoxes << new QStandardItem();
typeCheckBoxes[i]->setText(typeNames[i]);
typeModel->setItem(i, 0, typeCheckBoxes[i]);
typeCheckBoxes[i]->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
typeCheckBoxes[i]->setData(Qt::Checked, Qt::CheckStateRole);
typeCheckBoxes[i]->setCheckable(true);
}
Thanks in advance.