Results 1 to 4 of 4

Thread: [QTableView] Custom selection behaviour

  1. #1
    Join Date
    Apr 2011
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default [QTableView] Custom selection behaviour

    Hi,

    I'm new on this forum, so here is a short introduction.
    My alias is Rid, I'm French, and I'm praticing Qt since January 2010.

    I have a question concerning the way items are selected within a QTableView and the way we can modify it.
    Indeed, if I select an item, hold Shift-Key and then select*another item, this is what I get:


    I would like to modify this behaviour in order to select every items between the selected ones as in
    this screenshot:


    I've made some tests in which I modified QTableView's select mode and behaviour, but they failed.
    Can somebody give me help on this problem?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: [QTableView] Custom selection behaviour

    Salut!

    What's about C1 and D1? And please attach the images at this forum and don't use 3rd party sites. I don't know a "build in" function for that, but you could react on the signals of the selection model and make your own selection behavior. Or more sophisticated: make your own QItemSelectionModel and set it to your table view via QTableView::setSelectionModel().

  3. The following user says thank you to Lykurg for this useful post:

    Rid (4th May 2011)

  4. #3
    Join Date
    Apr 2011
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: [QTableView] Custom selection behaviour

    Thanks for your answer Lykburg.

    As I was unable to code what I wanted, I've used OpenOffice to make my screenshots, and I forgot to select C1..
    I think I will try to make my own QItemSelectionModel. I will update this thread...

  5. #4
    Join Date
    Apr 2012
    Location
    India.
    Posts
    88
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: [QTableView] Custom selection behaviour

    You derive new class from QTableView and handle mouse press and release event. In mouse press event store start cell index and on mouse release store end cell index and then in mouse release handler, you can clear current selection and write algorithm which makes list of cells which needs to be selected based on start cell index and end cell index and add list in selection model of the table.

    This is the way of custom handling of QTableView selection, I hope this is clear.

Similar Threads

  1. remove selection behaviour of icons inside QTableWidget
    By thejester in forum Qt Programming
    Replies: 0
    Last Post: 8th September 2010, 08:39
  2. Replies: 2
    Last Post: 19th April 2010, 12:49
  3. Replies: 2
    Last Post: 26th November 2009, 04:45
  4. selection behaviour in a TableView
    By Vanpark in forum Qt Programming
    Replies: 0
    Last Post: 1st April 2009, 13:34
  5. QAbstractItemView selection behaviour issue
    By Caius Aérobus in forum Qt Programming
    Replies: 4
    Last Post: 1st May 2007, 16:33

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.