Results 1 to 1 of 1

Thread: QTableWidget with a column of buttons. How do I get whichone is clicked?

  1. #1
    Join Date
    Apr 2019
    Posts
    13
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QTableWidget with a column of buttons. How do I get whichone is clicked?

    Hi all,
    I search on the previous post does not go well, so I'm asking here a probabibly basic question.

    My table has 6 columns, the last one is populated by buttons.

    I would like to know with row is associated to the button clicked by the user.

    I know that I can get the cell selected:

    Qt Code:
    1. self.table.cellClicked.connect(self.cell_was_clicked)
    To copy to clipboard, switch view to plain text mode 

    but this does not work with the click on the buttons: the click on button needs their module to be specified in the connect.

    The table is populate in a for loop like this:
    Qt Code:
    1. rowPos=self.table.rowCount()
    2. self.table.insertRow(rowPos)
    3. self.table.setItem(rowPos,0,QTableWidgetItem(str(status)))
    4. self.table.setItem(rowPos,1,QTableWidgetItem(str(snapshotID)))
    5. self.table.setItem(rowPos,2,QTableWidgetItem(str(avdPath)))
    6. self.table.setItem(rowPos,3,QTableWidgetItem(str(filename)))
    7. self.table.setItem(rowPos,4,QTableWidgetItem(str(filetype)))
    8. self.table.setCellWidget(rowPos,5,showBtn)
    To copy to clipboard, switch view to plain text mode 

    Thanks in advance
    M


    Added after 5 minutes:


    self.table.currentRow() is the answer.
    M
    Last edited by mcanonic; 20th June 2019 at 11:04.

Similar Threads

  1. Replies: 4
    Last Post: 5th June 2014, 22:34
  2. QTableWidget cell clicked
    By Archa4 in forum Newbie
    Replies: 5
    Last Post: 6th April 2011, 13:08
  3. Replies: 1
    Last Post: 23rd January 2010, 23:04
  4. How to get all column data on row clicked
    By wirasto in forum Qt Programming
    Replies: 7
    Last Post: 9th November 2009, 06:21
  5. How to find which column clicked from a treeview.
    By mekos in forum Qt Programming
    Replies: 2
    Last Post: 4th August 2008, 17: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.