Results 1 to 3 of 3

Thread: SelectionModel

  1. #1
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default SelectionModel

    Hi,

    I'm using QItemSelectionModel and setting this in my QTableView. My QTableView has a number of rows, but in the fifth column of each row it has a QToolButton. I have set up a signal for when the user clicks the button and within that signal I have the following code :

    Qt Code:
    1. QModelIndex s = m_pselectionModel->currentIndex();
    To copy to clipboard, switch view to plain text mode 

    Now I thought this would give me the row number for which the button that was clicked on actually resides in, but it doesn't, it only does this if I highlight one of the other columns within the QTableView. Is there a way of doing this?

    Regards,
    Steve

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

    Default Re: SelectionModel

    If you have set a widget using setIndexWidget() then you need to get the proper index using indexWidget() - for example by iterating over indexes and comparing their indexWidget pointers to your button. Or use a QSignalMapper or don't use index widgets but instead use the delegate approach.

  3. #3
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: SelectionModel

    Thanks,

    I've gone down the QSignalMapper route and it works a treat.

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.