PyQt QScrollView/QGridLayout question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Samir Grover

    PyQt QScrollView/QGridLayout question

    folks,

    I am trying put some user input fields into a scrollable (QScrollView)
    window. So,
    I placed a QLabel at 0,0 and QLineEdit at 0,1, next to QLabel.

    Somehow, results are not what I am expecting.It is placing QLineEdit
    below QLabel.
    I am not using designer for this. Please, notice that I convert vbox's
    box layout into
    grid layout, so that, I can place QLabel at 0,0 and QLineEdit at 0,1.
    But it does not
    do that. any advice on correcting this piece of code will be helpfull.
    regards,

    here is how this code looks like:

    -----
    import sys, qt
    from qt import *


    class MyDialog(QDialo g):
    def __init__(self,p arent = None,name = None,modal = 0,fl = 0):
    QDialog.__init_ _(self,parent,n ame,modal,fl)

    if not name:
    self.setName("M yDialog")

    self.setSizeGri pEnabled(1)

    self.build_wind ow()

    def build_window(se lf):

    toplayout = QGridLayout(sel f,1,1,11,6,"top layout")
    vbMain = qt.QVBox(self)
    toplayout.addWi dget(vbMain, 0, 0)

    sview = qt.QScrollView( vbMain)
    vp = sview.viewport( )
    vbox = qt.QVBox(vp)
    sview.addChild( vbox)

    vplayout = qt.QGridLayout( vp, 0, 0, 1,-1, 'vpl')
    vplayout.addWid get(vbox, 0, 0)

    grid = qt.QGridLayout( vbox.layout(), 2, 2)

    ll = qt.QLabel('circ uit name', vbox)
    grid.addWidget( ll, 0,0, qt.Qt.AlignLeft )

    nameinput = qt.QLineEdit(vb ox)
    grid.addWidget( nameinput, 0,1, qt.Qt.AlignLeft )

    if __name__ == "__main__":
    app = QApplication(sy s.argv)
    f = MyDialog()
    f.show()
    app.setMainWidg et(f)
    app.exec_loop()


Working...