PDA

View Full Version : how to enable buttons when multiple rows are selected in QTableWidget?



Qqt
6th March 2011, 07:39
Hello,

I am using QTableWidget in 4.3 to view a table of data, it works fine to select row(s).

Now I want to add a button which is ENABLED when there are multiple rows are selected in the table. I understand I have to pass a bool value to the button.SetEnable(bool), but where can I get this bool value from QTableWidget?

Thanks.

stampede
6th March 2011, 07:46
You can use QTableWidget::getSelectedRanges (http://doc.qt.nokia.com/latest/qtablewidget.html#selectedRanges) to know how many rows are currently selected.

Qqt
6th March 2011, 08:17
Thanks for reply.
But when can I check the selected range? I guess there must be a signal I can catch when there are selections in the table, then I can check the selection range there? Can you help again? Thanks.

stampede
6th March 2011, 08:20
There is a signal itemSelectionChanged (http://doc.qt.nokia.com/latest/qtreewidget.html#itemSelectionChanged) in QTreeWidget, I guess it could be good idea to use it (and read docs as well;)).

Qqt
6th March 2011, 09:54
Thank you for the help