QTableView and Checkable data
-
Hi. I want display QCheckBox in the first Column of the QTableView. How can I set userChaeckable flag? Сan be an example.
-
see the class QxtTableWidgetItem "LIBQXT":http://libqxt.org/
-
Your model should include Qt::ItemIsUserCheckable in the flags that are returned for the indexes in the first column.
Are you using a QTable View or a QTable Widget?
-
I'm using QTableView, can you write an example?
-
You have to return the Qt::ItemIsUserCheckable as (one of your) flags from the flags() method of your model, and return a valid value in your data() method for the Qt::CheckStateRole. What model are you using?
-
Hello
I do that in the model :
@...
index = (modelTab)->index(row, col, QModelIndex());
value =(((modelTab)->data(index)).toString());modelTab->itemFromIndex(index)->setCheckable(true);
if (value=="true") {
modelTab->item(row, col)->setCheckState(Qt::Checked);
}@with :
@QStandardItemModel *modelTab@Fred
-
Then just call setCheckable(true) on your QStandardItem for the first column.
-
it is clearer like that, thanks VolKer
-
Ok, I set setCheckable(true) for first column and how I get namber or index of checked?
-
Use the itemChanged signal from QStandardItemModel.
-
[quote author="Sidny Sho" date="1332273888"]Ok, I set setCheckable(true) for first column and how I get namber or index of checked?[/quote]
UseQStandardItemModel::findItems() or QAbstractItemModel::match().