View Full Version : Insert QCheckBox into QTableView
wind
5th October 2006, 17:51
How to insert a QCheckBox into a QTableView?
The problem is that the checkbox changes when i insert it:
http://files.lagoji.si/checkbox.PNG
The third column is a checkbox.
wysota
5th October 2006, 17:56
Simply make sure the flags() method for your model returns Qt::ItemIsUserCheckable and set its Qt::CheckStateRole to something valid.
wind
8th October 2006, 15:31
Ok. So i subclassed QStandardItemModel, reimplement flags() and make it return
Qt::ItemIsUserCheckable.
Then i added a checkbox to model:
model->setData(index, Qt::Checked, Qt::CheckStateRole);
How to get some notification when the state of the checkbox is changed?
jpn
8th October 2006, 17:15
The QAbstractItemModel::dataChanged() signal is emitted when the CheckState is changed. To add your own signals for more specific data changes, you can reimplement the QAbstractItemModel::setData() function and emit custom signals from there..
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.