Check/UnCheck all checkbox in QTableView
-
Dear Friends, I am a new developer, learning qt. I would like to know is it possible to add a check box column in QTableView column and to use a check box in the column header. From the column header checkbox can we check/uncheck the column checkboxes. Can anyone please provide a solution how can we achieve this.
-
Dear Friends, I am a new developer, learning qt. I would like to know is it possible to add a check box column in QTableView column and to use a check box in the column header. From the column header checkbox can we check/uncheck the column checkboxes. Can anyone please provide a solution how can we achieve this.
-
Dear Friends, I am a new developer, learning qt. I would like to know is it possible to add a check box column in QTableView column and to use a check box in the column header. From the column header checkbox can we check/uncheck the column checkboxes. Can anyone please provide a solution how can we achieve this.
@Qt-Developer said in Check/UnCheck all checkbox in QTableView:
is it possible to add a check box column in QTableView
The view does not control the contents of the table, the model does. anyway it's possible:
QStandardItemModel model; model.insertColumns(0,3); model.insertRows(0,3); for(int i=0;i<3;++i){ model.setData(model.index(i,0),QStringLiteral("foo")); model.setData(model.index(i,1),QStringLiteral("bar")); model.setData(model.index(i,2),QStringLiteral("foobar")); model.setData(model.index(i,0),Qt::Unchecked,Qt::CheckStateRole); // displays the checkbox model.item(i,0)->setFlags(model.flags(model.index(i,0)) | Qt::ItemIsUserCheckable); // allows the user to interact with the checkbox }