Results 1 to 3 of 3

Thread: pyqt4 reading values from rows of QTableWidget

  1. #1
    Join Date
    Jul 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default pyqt4 reading values from rows of QTableWidget

    Hi,
    I am new to pyqt and have been looking for examples of how to iterate through a QTableWidget to get the values. I can't seem to find anything online(probaly looking for the wrong keywords). Each row of my table consists of a default text field in the first column and comboBoxes in the second and third columns. I need to iterate through each row get the string from the first column and the option picked in each combobox. Any simple examples would be much appreciated
    Thanks in advance
    Stephen

  2. #2
    Join Date
    Jul 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: pyqt4 reading values from rows of QTableWidget

    ok ... after a few hours I think I have figured it out...
    the function that reads the table is like so ..
    Qt Code:
    1. def addNewPasses(self):
    2. allRows = self.ui.tableWidget.rowCount()
    3. for row in xrange(0,allRows):
    4. twi0 = self.ui.tableWidget.item(row,0)
    5. twi1 = self.ui.tableWidget.cellWidget(row,1)
    6. twi2 = self.ui.tableWidget.cellWidget(row,2)
    7. print twi0.text()+' '+twi1.currentText()+' '+twi2.currentText()
    To copy to clipboard, switch view to plain text mode 
    if there is a better more streamlined way let me know!
    stephen

  3. #3
    Join Date
    Jan 2011
    Posts
    23
    Qt products
    Platforms
    Windows

    Default Re: pyqt4 reading values from rows of QTableWidget

    I am using QDateEdit & QComboBox in QTableWidget in few columns but if i try to use the above method its working fine for QComboBox but its not working for QDateEdit

    i have set QDateEdit in 1st column of the table & i am trying to access that using below line

    date_applfrm = self.leaves_app_table.cellWidget(i,0)
    self.date_applfrm.date()

    its saying unknown attribute date_applfrm (error is for the 2nd line)

    can some one plz help me on this...
    thanx in advance
    Last edited by ad3d; 10th January 2011 at 10:02.

Similar Threads

  1. How to QTableWidget default values on insertion?
    By RawArkanis in forum Qt Programming
    Replies: 1
    Last Post: 20th April 2010, 07:02
  2. Replies: 0
    Last Post: 9th March 2010, 13:02
  3. QextSerialPort reading error: wrong values
    By Lawand in forum Qt Programming
    Replies: 9
    Last Post: 6th May 2009, 19:29
  4. Reading values from file to array
    By Jeo_ in forum Newbie
    Replies: 0
    Last Post: 24th April 2009, 18:05
  5. How to set rows of QtableWidget to the same height?
    By sawerset in forum Qt Programming
    Replies: 3
    Last Post: 7th December 2008, 18:09

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.