PyQt QScrollView/QGridLayout question

Samir Grover samirg at
Sat Jul 12 00:57:14 CEST 2008


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.

here is how this code looks like:

import sys, qt
from qt import *

class MyDialog(QDialog):
    def __init__(self,parent = None,name = None,modal = 0,fl = 0):

        if not name:



    def build_window(self):

	toplayout = QGridLayout(self,1,1,11,6,"toplayout")
        vbMain = qt.QVBox(self)
	toplayout.addWidget(vbMain, 0, 0)

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

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

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

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

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

if __name__ == "__main__":
    app = QApplication(sys.argv)
    f = MyDialog()

More information about the Python-list mailing list