PDA

View Full Version : Event handlers for QTableView model / selection model.



hickscorp
7th June 2011, 15:17
Hello there :)

i have a question which should be easy to answer for most of you... But still im stuck :)

i have a QTableView displaying data from a custom model. The selection model of this former table is connected to an object of mine thru the following slot:

selectionChanged(QItemSelection const&, QItemSelection const &)
However, the slot gets called only when clicking a record on the table... For instance, if i push Ctrl + A on the keyboard, and all the rows gets selected, i won't get notified with the slot.

Any idea please?
Best,
Pierre.

Santosh Reddy
8th June 2011, 01:36
i have a QTableView displaying data from a custom model.
Do you use QTableView or a custom QTableView, I assume it is custom class based of QTableView.


The selection model of this former table is connected to an object of mine thru the following slot:
It is not clear to me how you are connecting it to an object, is it using connect() or directly calling the slot?

Just in case try setting the selection mode to QAbstractItemView::ExtendedSelection

hickscorp
8th July 2011, 17:57
Do you use QTableView or a custom QTableView, I assume it is custom class based of QTableView. Just in case try setting the selection mode to QAbstractItemView::ExtendedSelection
You assumed wrong :) i'm using a plain vanilla QTableView, and i'm really connecting to it's selection model via signals / slots.
i have tried setting the selection model to Extended already... My slot connected to the selection model (to selectionChanged) is called when i click a record... But when i hit Ctrl + A, it's not called. Also, if i select a record and then click elsewhere in the table, the record gets de-selected, but the slot never called neither.

Bump, help please? Bellow is a snippet on how i connect to the selection model... i really think there is a bug here.
Thanks,
Pierre.


connect(ui.tblVwDocumentTypes->selectionModel(), SIGNAL(selectionChanged(QItemSelection const&, QItemSelection const &)), this, SLOT(documentTypesModel_selectionChanged(QItemSele ction const&, QItemSelection const&)));
- ui.tblVwDocumentTypes being my table view,
- documentTypesModel_selectionChanged being my slot.

Added after 5 minutes:

Oh boy... i have cleaned the solution and re-built.... The slots get called now. i had a very similar problem a while ago after i compiled another version of Qt on another project... i believe VS2008 objects cache time-stamping has some issues, never had the problem with linux / mac.

For you all... VS2008 users: Solution -> Clean and rebuild!

Thanks anyways,
Pierre.