Results 1 to 4 of 4

Thread: QTableView selection pattern

  1. #1
    Join Date
    Jul 2012
    Posts
    248
    Thanks
    29
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Smile QTableView selection pattern

    Hi,


    Say i have a QTableWidget with a bunch of rows and columns. I i start selecting from the middle of a row and pull my mouse down, then it will only select one 'column' of items. However, i would like it to select ALL items between start and end of my selection.


    i have illustrated this here (behold my paint skills):

    https://i.imgur.com/9FBPr5I.png



    I have tried to catch the selectionChanged() signal and remodel the selection there (ie, iterate all items, check if they are "within" the selection, and select them if they are). However, that is very, very slow and inefficient. Among other things the Qt will not recognice the "shape" of the selection and change it back automatically with every tiny mouse move.



    what would be the best way to make that happen?

    thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTableView selection pattern

    Reimplement QAbstractItemView::setSelection() for your table.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2012
    Posts
    248
    Thanks
    29
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableView selection pattern

    but that has the same deficit: the tableview will not know about this new selection "shape", so it will fire selection changed events continuously, even if the selection hasnt actually changed...

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTableView selection pattern

    Quote Originally Posted by tuli View Post
    but that has the same deficit: the tableview will not know about this new selection "shape", so it will fire selection changed events continuously, even if the selection hasnt actually changed...
    How did you reimplement setSelection()? I just checked it and it works as expected.
    Last edited by wysota; 19th August 2014 at 15:48.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Help with QTableView row selection
    By ScabrusMantra in forum Qt Programming
    Replies: 1
    Last Post: 13th April 2010, 21:44
  2. Replies: 2
    Last Post: 26th November 2009, 04:45
  3. QTableView - model / view pattern - layout, edit
    By vlastagf in forum Qt Programming
    Replies: 4
    Last Post: 1st August 2009, 22:42
  4. QTableView Row Selection
    By ToddAtWSU in forum Qt Programming
    Replies: 8
    Last Post: 12th December 2007, 21:27
  5. QTableView row selection
    By davemar in forum Qt Programming
    Replies: 2
    Last Post: 5th December 2007, 14:39

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
  •  
Qt is a trademark of The Qt Company.