PDA

View Full Version : QTableWidget with QCheckBox



reinki0013
7th December 2009, 13:48
Hello,

I want to insert in my QTableWidget a Checkbox...
I don`t know how I can do that...

For example:
In the first column have to be the Checkbox and in the second a QString...

MSUdom5
7th December 2009, 14:49
Check the Qt Examples and Demos, under the Widgets section, see the Icons demo. It has an example of what you're describing.

reinki0013
7th December 2009, 15:23
thanks...

but i can`t found something about that what i want...
do you have a little code example for me?

tsp
7th December 2009, 15:49
It might not be possible to put QCheckBox for QTableWidget instead you need to put QTableWidgetItem item to table and then mark that as checkable. Next piece of code shows one way to add "checkboxes" for table:



QTableWidgetItem *checkBoxItem = new QTableWidgetItem();
checkBoxItem->setCheckState(Qt::Unchecked);
table->setItem(row, column, checkBoxItem);

MSUdom5
7th December 2009, 16:25
Seriously, look here:

http://doc.trolltech.com/4.6/widgets-icons.html

In this example, in the bottom left corner, there's a TableWidget with a checkbox (as well as other widgets). There are links to code examples.

reinki0013
8th December 2009, 08:34
hi guys,

thanks a lot for your help...
it works :rolleyes:

bye