Bruno-Pierre Jobin wrote:
>
> I'm sure this is an easy one for you guys. How can I make the
> QComboBox drive the amount of rows of the QTableWidget. For example, I
> want the amount of rows to reflect the selected index of the comboBox
> and it needs to reset itself every time I select a new index.

You haven't thought through your code.  Look at what you are doing. 
Every time you change the combo box, you are creating a BRAND NEW table
object.  That's clearly not what you want.  Just create the table in its
initial state, and only update the row count in the combo box handler:

    from PySide.QtGui import *
    from PySide.QtCore import *

    class Panel(QWidget):
        def __init__(self):
            super(Panel, self).__init__()

            self.table = QTableWidget()
            self.table.setColumnCount(2)
            self.table.setRowCount(1)

            self.combo = QComboBox()
            self.combo.addItems(['1','2','3','4'])
            self.vlayout = QVBoxLayout()
            self.vlayout.addWidget(self.combo)
            self.vlayout.addWidget(self.table)
            self.setLayout(self.vlayout)

            self.resize(400,200)

           
    
self.combo.currentIndexChanged.connect(lambda:self.buildTable(self.combo.currentText()))

        def buildTable(self, date):
            print 'set rows : ', int(date)
            self.table.setRowCount(int(date))

    def start():
        start.panel = Panel()
        start.panel.show()

    import sys
    app = QApplication(sys.argv)
    start()
    app.exec_()


-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

_______________________________________________
PySide mailing list
PySide@qt-project.org
http://lists.qt-project.org/mailman/listinfo/pyside

Reply via email to