Answer the question
In order to leave comments, you need to log in
Qt checkbox this combobox?
I want to make a drop-down list with a CheckBox, so that when a ChexkBox is selected, it will be displayed in the ComboBox itself? an example is the "Question tags" field on the page https://toster.ru/question/new
I create a ComboBox with ChexkBox like this
QStandardItemModel *model = new QStandardItemModel();
for(int i=0;i<50;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);
connect(?, ?, this, &form::onSetActivated);
Answer the question
In order to leave comments, you need to log in
I don't see a way through signals-slots.
Inherit from QStandardItemModel, stick on setModelData.
Better yet, inherit from QAbstractTableModel and override all these data(), flags()…
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question