Results 1 to 5 of 5

Thread: Simple QScrollArea problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2008
    Posts
    53
    Thanks
    10

    Default Simple QScrollArea problem

    Hi,

    I'm not seeing my widget window when I'm trying put it into a QScrollArea with QFrame.

    I designed a gui (MyWidget) using designer.

    I placed all the buttons of my gui inside of a QFrame (like Wysota suggested in another thread), and then promoted the QFrame to QScrollArea and called it scrollFrame.

    So in my code, my constructor looks like this:

    Qt Code:
    1. MyWidget::MyWidget (QWidget *parent, Qt::WFlags flags)
    2. : QWidget(parent, flags)
    3. {
    4. ui.setupUi(this);
    5. ui.scrollFrame->setWidget(this);
    6. }
    To copy to clipboard, switch view to plain text mode 

    My main looks like this:
    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication a(argc, argv);
    4. MyWidget w;
    5. w.show();
    6.  
    7. return a.exec();
    8. }
    To copy to clipboard, switch view to plain text mode 

    However nothing shows up when I try to run this. Can somebody please help me figure out how to bring up the scrollbars?

    Thank you.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: Simple QScrollArea problem

    Hi,
    Quote Originally Posted by jmsbc View Post
    Qt Code:
    1. ui.setupUi(this);
    2. ui.scrollFrame->setWidget(this);
    To copy to clipboard, switch view to plain text mode 
    I'm sorry, but this code doesn't make any sense. You have a window. First you load a designed form on the window. At this stage the window contains a scroll area. Then you try to set the window inside that scroll area.

    PS. Please don't double post!
    Last edited by jpn; 2nd December 2008 at 18:23.
    J-P Nurmi

  3. #3
    Join Date
    Apr 2008
    Posts
    53
    Thanks
    10

    Default Re: Simple QScrollArea problem

    Crap you're right sorry about that.

    Let's say I have a calendar widget inside of the QScrollArea's QFrame and then I do

    Qt Code:
    1. ScrollTest::ScrollTest(QWidget *parent, Qt::WFlags flags)
    2. : QMainWindow(parent, flags)
    3. {
    4. ui.setupUi(this);
    5. ui.scrollFrame->setWidget(ui.calendarWidget);
    6. }
    To copy to clipboard, switch view to plain text mode 

    This will show me the window with calenderWidget, but when I resize the window smaller than the calendar, scrollbars do not show up.

    I'm probably doing something really wrong, please help!

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: Simple QScrollArea problem

    Quote Originally Posted by jmsbc View Post
    This will show me the window with calenderWidget, but when I resize the window smaller than the calendar, scrollbars do not show up.
    You're probably missing the top level layout. See Setting A Top Level Layout for more details.
    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    jmsbc (2nd December 2008)

  6. #5
    Join Date
    Apr 2008
    Posts
    53
    Thanks
    10

    Default Re: Simple QScrollArea problem

    omg i'm retarded,

    Thanks a lot jpn!

Similar Threads

  1. Simple problem
    By s410i in forum Qt Programming
    Replies: 3
    Last Post: 22nd June 2008, 11:12
  2. qscrollarea slider problem
    By babu198649 in forum Qt Programming
    Replies: 4
    Last Post: 22nd November 2007, 12:51
  3. Replies: 2
    Last Post: 8th October 2006, 20:14
  4. QScrollArea problem positioning a QWidget inside
    By Spectator in forum Qt Programming
    Replies: 4
    Last Post: 20th February 2006, 22:59
  5. Problem with QScrollArea updating from 4.0.1 to 4.1.0
    By SkripT in forum Qt Programming
    Replies: 8
    Last Post: 28th January 2006, 22:35

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
  •  
Qt is a trademark of The Qt Company.