Results 1 to 3 of 3

Thread: Event handlers for QTableView model / selection model.

  1. #1
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Event handlers for QTableView model / selection model.

    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:
    Qt Code:
    1. selectionChanged(QItemSelection const&, QItemSelection const &)
    To copy to clipboard, switch view to plain text mode 
    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.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Event handlers for QTableView model / selection model.

    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

  3. #3
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Event handlers for QTableView model / selection model.

    Quote Originally Posted by Santosh Reddy View Post
    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.

    Qt Code:
    1. connect(ui.tblVwDocumentTypes->selectionModel(), SIGNAL(selectionChanged(QItemSelection const&, QItemSelection const &)), this, SLOT(documentTypesModel_selectionChanged(QItemSelection const&, QItemSelection const&)));
    To copy to clipboard, switch view to plain text mode 
    - 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.
    Last edited by hickscorp; 8th July 2011 at 17:57.

Similar Threads

  1. Replies: 1
    Last Post: 24th February 2011, 05:54
  2. Replies: 1
    Last Post: 18th November 2009, 23:21
  3. Catch a row selection event in QTableView
    By Windsoarer in forum Qt Programming
    Replies: 1
    Last Post: 2nd March 2009, 22:44
  4. Model sorting vs. selection
    By VlJE in forum Qt Programming
    Replies: 2
    Last Post: 25th October 2006, 16:46
  5. Replies: 2
    Last Post: 16th February 2006, 19:09

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.