Results 1 to 2 of 2

Thread: Working out table's current row from pushbutton click

  1. #1

    Default Working out table's current row from pushbutton click

    Hi,

    I've got a table, and when I create a new row I create a new pushbutton to go into the last column of the new row. I'm trying to workout how to get the currentRow when clicking the pushbutton without selecting the row.

    I've got this pseudo code

    Qt Code:
    1. def printThis(self):
    2. currentRow = self.table.currentRow()
    3. print currentRow
    4.  
    5. def addRow(self):
    6. newButton = QPushButton(Qstring('push'))
    7. self.connect(newButton,SIGNAL("clicked()"),self.printThis)
    8.  
    9. newRow = self.table.rowCount()
    10. self.table.insertRow(newRow)
    11. #set table widget items
    12. self.table.setCellWidget(newRow, 3, newButton)
    To copy to clipboard, switch view to plain text mode 

    Help please?
    Last edited by jpn; 17th March 2008 at 20:32. Reason: missing [code] tags

  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: Working out table's current row from pushbutton click

    You can use QSignalMapper and map between buttons and row numbers. Or you can use dynamic properties to set some hidden data or you can just have an equivalent of QHash<QPushButton*, int> where you will store row numbers.

Similar Threads

  1. Distributing QT application for Mac OS
    By mb0 in forum Qt Programming
    Replies: 1
    Last Post: 31st May 2007, 18:59
  2. Replies: 15
    Last Post: 21st April 2007, 17:46

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.