connecting CheckBox inside QTableWidget with a function
Hi,
i have a QGraphicsItem that i want to be hidden or shown, due to its checkmark which i want to place inside a TableWidget. What i have so far:
Code:
item->data(Qt::CheckStateRole);
item->setCeckState(Qt::Checked);
table->setItem(3,0,item);
... which creates a wonderful CheckBox inside my table. But how can i link the check mark state to my GraphicsItem?
I tried several signals provided by the QTableWidget class, but some of the ones i tried produced a compiler error stating, that this signal doesn't exist. And the others that work, don't seem to be appropriate for my problem.
Thanks in advance!
Re: connecting CheckBox inside QTableWidget with a function
Quote:
Originally Posted by
Merkura
But how can i link the check mark state to my GraphicsItem?
I tried several signals provided by the QTableWidget class, but some of the ones i tried produced a compiler error stating, that this signal doesn't exist. And the others that work, don't seem to be appropriate for my problem.
QTableWidget::itemChanged() is the closest you can get with available signals. You just have to keep in mind that it gets emitted whenever any item data changes, not just check state. A signal like checkStateChanged() has been requested but unfortunately Trolltech rejected the idea. See also QxtTableWidget.
Re: connecting CheckBox inside QTableWidget with a function
You can set the pointer to your graphics item in the QTableWidgetItem (setData()), then use the QTableWidget signal itemClicked(QTableWidgetItem* item) & see if it's in the right column, or data() != NULL, or some other way to validate that it's one of your checkbox items. Then you can use the pointer to show/hide as needed.
Vycke