Results 1 to 3 of 3

Thread: Getting the row for button pressed

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

    Default Getting the row for button pressed

    Hi,

    I've got a QTableView with five rows and five columns. In the fifth column of each row I have a QToolButton widget which is connected to the click signal and all go to the same slot. My problem is, I need to know which row is selected when the user has clicked on the button.

    Qt Code:
    1. connect( button, SIGNAL(clicked()),this,SLOT(SendAMessage()) );
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void CSignal::SendAMessage()
    2. {
    3. // how can I get which row is selected?
    4.  
    5. }
    To copy to clipboard, switch view to plain text mode 

    I cannot do this :

    Qt Code:
    1. connect(ui.tableView, SIGNAL(clicked(QModelIndex)), this, SLOT(GetSelectedRow( QModelIndex )));
    To copy to clipboard, switch view to plain text mode 

    As the button click event is signalled first.

    Any ideas?

    Thanks,
    Steve

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Getting the row for button pressed

    See QItemSelectionModel. You can get one by calling QAbstractItemView::selectionModel(). Other solution is to use QSignalMapper.

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

    Default Re: Getting the row for button pressed

    Thanks Jacek, I will go take a look.

Similar Threads

  1. QTableView key pressed
    By radu_d in forum Qt Programming
    Replies: 6
    Last Post: 1st August 2013, 03:20
  2. Painting Faded away when alt key pressed,
    By rajeshs in forum Qt Programming
    Replies: 2
    Last Post: 4th July 2007, 09:45
  3. Replies: 5
    Last Post: 9th March 2007, 12:51
  4. MenuBar grabs the focus on ALT pressed.
    By Cutey in forum Qt Tools
    Replies: 7
    Last Post: 16th January 2007, 09:59
  5. MenuBar grabs focus on ALT pressed.
    By Cutey in forum Qt Programming
    Replies: 2
    Last Post: 9th January 2007, 11:45

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.