View Full Version : Qt tree widget with check boxes iteration

30th October 2010, 16:03
Hi there,

I just started learing Qt and I am trying to create a Tree widget which will have only one column and the items will have check boxes. So i managed to achieve that, and now begins my problem.

What I want fist is every time i check on one tree item, I want to print the text of the item on a EditText area, and when I am unchecking it to remove it from the EditText area . So my issues are 2: I cant find a way to get the text from the tree item, and also at the signal- slots there is no choice for check box in the tree item, but just for selection double click and etc.

Any help is really appreciated

Thanks Nick

9th November 2010, 14:24
Hi Nick,

In setData which is where I presume you check your item, use the following to get the text:

QString text = index.internalPointer()->data( index, Qt::DisplayRole ).toString();

Once this done you could emit a custom signal with the text of interest. Also, if you have written setData remember to
emit dataChanged( index, index );

Caveat: I haven't tested this code but I think it should work...