Results 1 to 8 of 8

Thread: How to get the selected row when click the button in it?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Join Date
    Mar 2009
    Location
    Gansu,China
    Posts
    188
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to get the selected row when click the button in it?

    Quote Originally Posted by Santosh Reddy View Post
    You need to associate each button with the row number, when you create the button. One way to do so is sub-class QPushButton and add a member variable (say buttonRow), and store the row number in it when you create the button. Now in the slot connected to clicked signal, check the member var.
    Could you explain"check the member var"?
    I sub-class QPushButton as follows:
    Qt Code:
    1. myPushButton :public QPushButton
    2. {
    3.  
    4. public :
    5. myPushButton (QString txt,int mrow);
    6. private:
    7. int row;
    8. }
    To copy to clipboard, switch view to plain text mode 
    and use it as follows:
    ...
    Qt Code:
    1. for(int i=0;i<count();i++)
    2. {
    3. ....
    4. myPushButton *myBtn=new myPushButton("convert",i);
    5. connect(myBtn,SIGNAL(clicked()),this,convertSlot());
    6.  
    7. }
    8. ...
    9.  
    10. void TableMyclass::convertSlot()
    11. {
    12. how to check the row?
    13. }
    To copy to clipboard, switch view to plain text mode 
    ...
    Last edited by weixj2003ld; 10th November 2011 at 07:59. Reason: sorry

Similar Threads

  1. Disable button click
    By "BumbleBee" in forum Newbie
    Replies: 19
    Last Post: 30th March 2011, 13:16
  2. How to prohibit click to button
    By somename in forum Qt Programming
    Replies: 8
    Last Post: 27th May 2010, 22:32
  3. How can I know which button click.
    By electronicboy in forum Qt Programming
    Replies: 10
    Last Post: 4th October 2009, 14:27
  4. button click in webview
    By mind_freak in forum Qt Programming
    Replies: 1
    Last Post: 29th September 2009, 13:48
  5. QPaintEvent on button click?
    By vishal.chauhan in forum Qt Programming
    Replies: 1
    Last Post: 5th June 2007, 08:44

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.