[PyQt] PyQt : QScrollView/QGridLayout question

samirg samirgrover at yahoo.com
Tue Jul 15 00:23:15 BST 2008


I am trying create a widget (QVBox)  with grid layout in QScrollView which
is inside QDialog.

I place 2 user input fields into this widget, namely, 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 wisget'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()

View this message in context: http://www.nabble.com/PyQt-%3A-QScrollView-QGridLayout-question-tp18455269p18455269.html
Sent from the PyQt mailing list archive at Nabble.com.

More information about the PyQt mailing list