Results 1 to 5 of 5

Thread: Trying to add a scrollArea to contain a long sequence of QLineEdits

  1. #1
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    124
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Trying to add a scrollArea to contain a long sequence of QLineEdits

    Hi
    I developped a window with lots of entry fields, so many that the whole thing doesnt fit onto my screen. So I thought one way out would be to create a scroll area and let the user scroll though this.
    Trouble is, all my trials have come to nothing. I was hoping to have a minimal change
    Here is the constructor for my window:
    Qt Code:
    1. MyWindow::MyWindow(QMainWindow *parent)
    2. {
    3.  
    4. this->m_scrollArea = new QScrollArea;
    5. m_scrollArea->setBackgroundRole(QPalette::Light);
    6. setCentralWidget(m_scrollArea);
    7. this->m_frame = new QFrame(this);
    8. this->m_vLayout = new QVBoxLayout(m_frame);
    9. m_scrollArea->setWidget(m_vLayout);
    10. // add entry fields and labels to m_vLayout below.
    11.  
    12.  
    13. }
    To copy to clipboard, switch view to plain text mode 
    I have of course defined some fields called m_scrollArea, m_frame, etc of the types that you would guess.
    When I display my window I just get one big blank area.
    Please tell me if you want more detail.
    I should add that my window derived from QDialog initially, and then I tried to derive it from QMainWindow in the above code.
    Last edited by feraudyh; 26th August 2010 at 19:13. Reason: more info

  2. #2
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Trying to add a scrollArea to contain a long sequence of QLineEdits

    I think that you are adding an empty frame to m_scrollArea. Try moving m_scrollArea->setWidget(m_frame) to below where you add widgets to your layout.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Trying to add a scrollArea to contain a long sequence of QLineEdits

    As norobro alludes, line 9 fails to compile (no matching call). Did you mean:
    Qt Code:
    1. m_scrollArea->setWidget(m_frame);
    To copy to clipboard, switch view to plain text mode 

    You can add the widget to the scroll area after you fill the layout, or you can:
    Qt Code:
    1. m_vLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
    To copy to clipboard, switch view to plain text mode 
    to handle the dynamic changes in the layout after you have installed the frame in the scroll area. See the detailed description of QScrollArea for stuff about dynamic layouts.

  4. The following user says thank you to ChrisW67 for this useful post:

    norobro (27th August 2010)

  5. #4
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Trying to add a scrollArea to contain a long sequence of QLineEdits

    I figured that was a typo since he said he was getting "one big blank area"

    Thanks for the setSizeConstraint() tip!

  6. #5
    Join Date
    Nov 2009
    Location
    Laval, France
    Posts
    124
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Trying to add a scrollArea to contain a long sequence of QLineEdits

    Yes, I must have copied the version that wouldnt compile. Sorry.

    Thanks guys, problem solved.
    Last edited by feraudyh; 27th August 2010 at 10:38. Reason: updated, case closed

Similar Threads

  1. ItemViews in ScrollArea
    By SElsner in forum Newbie
    Replies: 3
    Last Post: 4th June 2010, 23:59
  2. paint in the viewport of a scrollarea
    By franco.amato in forum Qt Programming
    Replies: 14
    Last Post: 30th March 2010, 03:22
  3. Autoscroll in ScrollArea
    By BalaQT in forum Qt Programming
    Replies: 2
    Last Post: 26th October 2009, 05:37
  4. scrollArea not updating
    By user in forum Qt Programming
    Replies: 9
    Last Post: 3rd October 2007, 08:17
  5. QTreeWidget without the ScrollArea?
    By Paalrammer in forum Newbie
    Replies: 5
    Last Post: 13th February 2007, 19:06

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.