QTableView QCheckBox QComboBox
How can I
display QCheckBox in the first Column of the QTableView, and QComboBox in several other columns.
get the signal from those QCheckBox and QComboBoxes
Thanks in advance
Views display checkboxes if the model has the userCheckable flag set, and the model returns valid data for the Qt::CheckStateRole.
To use a combo box as your editor, you will need to set an appropriate QItemDelegate subclass that creates a combobox as the editor widget.
The model will give you a generic dataChanged() signal if the data is modified. Depending your your model, you may get more specific signals from there.
thanks a lot, if the users edit,check or select any item from the GUI, can that dataChanged() signal be emit automatically? In my perspective, model is different with view.
If you create your own custom model, YOU must take care of signals like dataChanged etc.
To get more info on that, read "an editable model":http://doc.qt.nokia.com/4.7/model-view-programming.html#an-editable-model
QComboBoxes has already been displayed, but only double click the cells, the comboboxes will appear, I want those comboboxes appear as the tableview is displayed, how can I do for that, thanks in advance
That is how delegates work. You can set a widget for a table cell using setCellWidget, but it will not be very performant for larger data sets, and it goes against the grain of model view programming a bit.
Yes, the editor is created when the user starts editing the cell.
If you want your QComboBox to appear all the time, I guess you'll have to reimplement the paint method of your delegate and draw the QComboBox by yourself. See "QStyle::drawComplexControl":http://doc.qt.nokia.com/latest/qstyle.html#drawComplexControl
There's a wiki article "Combo Boxes in Item Views":http://developer.qt.nokia.com/wiki/Combo_Boxes_in_Item_Views that shows you how to create a [[Doc:QStyledItemDelegate]] subclass for that task.