Results 1 to 2 of 2

Thread: Nothing appears in QScrollArea

  1. #1
    Join Date
    Dec 2009
    Posts
    33
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Nothing appears in QScrollArea

    The following code appears in a custom dialog constructor:
    Qt Code:
    1. layout = QVBoxLayout()
    2.  
    3. watcher = DWatcher(None, DProperties({'value':settings}))
    4.  
    5. scroller = QScrollArea()
    6. scroller.setWidget(watcher)
    7. layout.addWidget(scroller)
    8.  
    9. layout2 = QHBoxLayout()
    10. layout2.addWidget(QPushButton('OK'))
    11. layout2.addWidget(QPushButton('Cancel'))
    12. layout.addItem(layout2)
    13.  
    14. self.setLayout(layout)
    To copy to clipboard, switch view to plain text mode 
    When the dialog appears, there is nothing in the scrollarea. DWatcher has a layout after its constructor exits. If I simply add the DWatcher, it works just like it's supposed to, but it can be really big so I want it in a scrollarea. Any ideas how this might happen?

  2. #2
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Nothing appears in QScrollArea

    From documentation:
    If the scroll area is visible when the widget is added, you must show() it explicitly.
    Note that You must add the layout of widget before you call this function (setWidget()); if you add it later, the widget will not be visible - regardless of when you show() the scroll area. In this case, you can also not show() the widget later
    Maybe the second line is your reason?

Similar Threads

  1.  appears in QTextBrowser
    By szisziszilvi in forum Qt Programming
    Replies: 1
    Last Post: 4th March 2011, 09:21
  2. QWidget::pos Appears Unreliable
    By mbrusati in forum Qt Programming
    Replies: 1
    Last Post: 25th February 2009, 18:01
  3. QPushButton appears differently
    By gianhut in forum Qt Tools
    Replies: 4
    Last Post: 5th January 2009, 23:08
  4. Replies: 2
    Last Post: 10th March 2008, 21:16

Tags for this Thread

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.