PyQt QScrollView/QGridLayout question

S

Samir Grover

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(QDialog):
def __init__(self,parent = None,name = None,modal = 0,fl = 0):
QDialog.__init__(self,parent,name,modal,fl)

if not name:
self.setName("MyDialog")

self.setSizeGripEnabled(1)

self.build_window()

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)
sview.addChild(vbox)

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()
f.show()
app.setMainWidget(f)
app.exec_loop()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top