Results 1 to 1 of 1

Thread: QGridLayout/QScrollView question

  1. #1
    Join Date
    Aug 2007
    Posts
    9
    Thanks
    3
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default QGridLayout/QScrollView 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:

    Qt Code:
    1. import sys, qt
    2. from qt import *
    3.  
    4.  
    5. class MyDialog(QDialog):
    6. def __init__(self,parent = None,name = None,modal = 0,fl = 0):
    7. QDialog.__init__(self,parent,name,modal,fl)
    8.  
    9. if not name:
    10. self.setName("MyDialog")
    11.  
    12. self.setSizeGripEnabled(1)
    13.  
    14. self.build_window()
    15.  
    16. def build_window(self):
    17.  
    18. toplayout = QGridLayout(self,1,1,11,6,"toplayout")
    19. vbMain = qt.QVBox(self)
    20. toplayout.addWidget(vbMain, 0, 0)
    21.  
    22. sview = qt.QScrollView(vbMain)
    23. vp = sview.viewport()
    24. vbox = qt.QVBox(vp)
    25. sview.addChild(vbox)
    26.  
    27. vplayout = qt.QGridLayout(vp, 0, 0, 1,-1, 'vpl')
    28. vplayout.addWidget(vbox, 0, 0)
    29.  
    30. grid = qt.QGridLayout(vbox.layout(), 2, 2)
    31.  
    32. ll = qt.QLabel('circuit name', vbox)
    33. grid.addWidget(ll, 0,0, qt.Qt.AlignLeft)
    34.  
    35. nameinput = qt.QLineEdit(vbox)
    36. grid.addWidget(nameinput, 0,1, qt.Qt.AlignLeft)
    37.  
    38. if __name__ == "__main__":
    39. app = QApplication(sys.argv)
    40. f = MyDialog()
    41. f.show()
    42. app.setMainWidget(f)
    43. app.exec_loop()
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 14th July 2008 at 21:23. Reason: missing [code] tags

Similar Threads

  1. Exceptions / setjmp/longjmp question
    By Aceman2000 in forum Qt Programming
    Replies: 3
    Last Post: 13th March 2008, 17:14
  2. Replies: 1
    Last Post: 15th March 2007, 20:45
  3. Question regarding how to paint after zoom.
    By JonathanForQT4 in forum Qt Programming
    Replies: 2
    Last Post: 26th January 2007, 15:34
  4. QThread exit()/quit() question
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 28th August 2006, 14:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.