PDA

View Full Version : QTableWidget item checkable and combo?



darpan
10th October 2006, 06:12
Hi,
Earlier i worked on QT3 and now working on QT4.I Placed QTableWidget on a form using QT Designer and Which have three column , I wants to take first column
(1) as Qcheckable item and
(2) second one as combo item.
How this can be achieved QTableWidgetItem using QT4. Please give me some example code.

In qt3 QChecktable item is inserted in QTable using
QCheckTableItem *item=new QCheckTableItem( table, "Nikon" );

and Qcombo item is inserted in QTable using
table->setItem( j, 3, new QComboTableItem ( table, KBMB, FALSE ) );


How this will be done in QT4 QTableWidget.

Thanks and Regards

jpn
10th October 2006, 07:12
Checkable items:
QTableWidgetItem::setFlags() and pass Qt::ItemIsUserCheckable amongst the others wanted flags. Initialize the check state with QTableWidgetItem::setCheckState().

Combo:
You'll get a combo out of the box If you set the data as a boolean value. That would be something like QTableWidgetItem::setData(Qt::EditRole, true/false). If you need more options than just true/false, you can always set a QComboBox as a cell widget by QTableWidget::setCellWidget().