LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-08-2016, 05:50 PM   #1
sharky
Member
 
Registered: Oct 2002
Posts: 569

Rep: Reputation: 84
PyQt4 QTableWidget with QComboBox


Creating a QTablewidget with 8 columns. The last five columns are filled with comboboxes using the following code.

Code:
    for col in xrange(3, 8):
      self.Choices = QtGui.QComboBox()
      self.Choices.addItems(['t','nil'])
      self.myTbl.setCellWidget(0 , col, self.Choices)
This works and the table is built with combo boxes set in the cells of the table widget.

How do I read back the values of all the combo boxes from the table? There could also be more rows created at runtime so I would need to read the values of all the comboboxes from all the rows and columns.

Thanks to all.
 
Old 07-10-2016, 12:23 PM   #2
sharky
Member
 
Registered: Oct 2002
Posts: 569

Original Poster
Rep: Reputation: 84
Turned out to be fairly simple.

Code:
    for row in range(0,self.myTbl.rowCount()):
      block1 = self.myTbl.item(row, 0).text()
      block2 = self.myTbl.item(row, 1).text()
      block3 = self.myTbl.item(row, 2).text()
      block4 = self.myTbl.cellWidget(row,3).currentText()
      block5 = self.myTbl.cellWidget(row,4).currentText()
      block6 = self.myTbl.cellWidget(row,5).currentText()
      block7 = self.myTbl.cellWidget(row,6).currentText()
      block8 = self.myTbl.cellWidget(row,7).currentText()
      print block1, block2, block3, block4, block5, block6, block7, block8
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PyQt4 qtablewidget question sharky Programming 4 07-08-2016 05:31 PM
[SOLVED] pyqt4 qtablewidget / select and/or highlight other cells when one is clicked. sharky Programming 4 02-23-2015 12:24 PM
[SOLVED] PySide vs PyQt4 problem sharky Programming 5 06-24-2014 01:41 PM
How do I know if I have PyQT4 installed using Ubuntu? ShaqDiesel Ubuntu 1 05-15-2013 01:37 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration