Results 1 to 2 of 2

Thread: scrollArea

  1. #1

    Default scrollArea

    I have created a scrollArea in the designer in Qt Creator. Its scrollAreaWidgetContents have a grid-layout. If I put in an object in the area in the designer, the scrollbar works fine. But if I create an object later in the code, the scrollbar doesn't work and the object is simply cut if the window is too small. What to do?

    To create an object in the scrollArea, I simply write:

    Qt Code:
    1. QGroupBox *b = new QGroupBox(mainWindow->scrollArea);
    2. b->resize(100,600);
    To copy to clipboard, switch view to plain text mode 

    The box show up in the scrollArea, in the top left corner.

    Last edited by Lykurg; 12th January 2011 at 14:03. Reason: missing [code] tags

  2. #2
    Join Date
    Jul 2009
    Enschede, Netherlands
    Thanked 69 Times in 67 Posts
    Qt products
    Unix/X11 Windows

    Default Re: scrollArea

    It's probably better to explicitly add your new widget to the scroll area:

    Qt Code:
    1. b->resize(100,600);
    2. mainWindow->scrollArea->setWidget(b);
    To copy to clipboard, switch view to plain text mode 

    It is probably bad style (read about encapsulation) to have member variables publicly (or even protected) available. Also, please use code tags on the forum when posting code.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

Similar Threads

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


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.