I have created model by using QListView and QAbstractListModel. Into that model i want to add, for example, 10 buttons and 10 checkboxes, and then display it using QListView.
How can i do it?
I have created model by using QListView and QAbstractListModel. Into that model i want to add, for example, 10 buttons and 10 checkboxes, and then display it using QListView.
How can i do it?
You don't need a model to achieve this, you can use a QListWidget
and add the widgets like this:
for (int i = 0; i < 10; ++i)
{
ui->listWidget->setItemWidget(new QListWidgetItem(ui->listWidget),
new QPushButton("Button " + QString::number(i + 1), ui->listWidget));
ui->listWidget->setItemWidget(new QListWidgetItem(ui->listWidget),
new QCheckBox("Checkbox " + QString::number(i + 1), ui->listWidget));
}
The result on KDE Desktop looks like this, if the QListWidget
is in a Gridlayout: