Results 1 to 6 of 6

Thread: Howto: Setup QScrollArea correct? - e.g. scrolling is not working...

  1. #1
    Join Date
    May 2009
    Location
    Vienna
    Posts
    91
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Howto: Setup QScrollArea correct? - e.g. scrolling is not working...

    Hi,

    I've created a scrollArea in a widget and added another widget "pjob" to it,
    But it does not scroll automatically as it's described in the Class Reference.
    (The Image Viewer example also was not a really help) In the Designer i set: Vertical: ScrollbarAlwaysOn and Horizontal: ScrollBarAsNeeded

    Do i have to tell the scrollArea the size of the widget pjob, or does that happen automatically?
    Do i need scrollAreaWidgetContents? (It's not in the Qt 4.5 docu ??)

    any ideas?
    Thanx Astronomy


    Qt Code:
    1. m_ui->setupUi(this);
    2. Jobs *pjob = new Jobs();
    3.  
    4. m_ui->scrollArea->setWidget(pjob);
    5. m_ui->scrollArea->setWidgetResizable(true);
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images
    Last edited by Astronomy; 1st September 2010 at 22:20.

  2. #2
    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: Howto: Setup QScrollArea correct? - e.g. scrolling is not working...

    The scroll area will take advice from the internal widget size hint. This is driven by the layout and content of the internal widget. Have a read of the detailed description section in the QScrollArea docs regarding Size Hints and Layouts and try playing with the layout's size constraint.

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

    Astronomy (17th September 2010)

  4. #3
    Join Date
    May 2009
    Location
    Vienna
    Posts
    91
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Howto: Setup QScrollArea correct? - e.g. scrolling is not working...

    OK Thank you,
    1st i thougt it might work automatically..
    but i'll dig in

    greetz Astronomy

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Howto: Setup QScrollArea correct? - e.g. scrolling is not working...

    Quote Originally Posted by Astronomy View Post
    OK Thank you,
    1st i thougt it might work automatically..
    It does but you didn't set a layout for the contents of the scroll area so it has no way of knowing how it should manage its own space.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. The following user says thank you to wysota for this useful post:

    Astronomy (17th September 2010)

  7. #5
    Join Date
    May 2009
    Location
    Vienna
    Posts
    91
    Thanks
    18
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up Re: Howto: Setup QScrollArea correct? - e.g. scrolling is not working...

    Hello again,

    today i had the time to solve this problem with your suggestions
    At: http://doc.trolltech.com/latest/qscr...html#setWidget
    is the hint:
    Note that You must add the layout of widget before you call this function; 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.

    With QLayout i had some problems, but at last:

    I had to set the minimum size of my custom widget, before i add it to the scrollArea.
    So everytime i change the size of pJob because of adding new functionyllity -eg widgets to it scrollArea will adapt automatically.

    i did at my constructor:

    Qt Code:
    1. ...
    2. m_ui->setupUi(this);
    3. Jobs *pjob = new Jobs();
    4.  
    5. QSize AdjustSize = pjob->size();
    6. AdjustSize.width(); // for debugging...
    7.  
    8. // Adjust scrollArea to this size,
    9. pjob->setMinimumSize(AdjustSize); // Advantage: everytime you change the size of pJob,
    10. // because of adding new functionyllity -eg widgets to it..
    11. // scrollArea will adapt automatically (-:
    12.  
    13. m_ui->scrollArea->setWidgetResizable(true);
    14. m_ui->scrollArea->setWidget(pjob);
    To copy to clipboard, switch view to plain text mode 

    Thank you very much,
    & have a nice day
    Astronomy
    Attached Images Attached Images
    Last edited by Astronomy; 17th September 2010 at 14:14.

  8. #6
    Join Date
    Jun 2013
    Posts
    1
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Re: Howto: Setup QScrollArea correct? - e.g. scrolling is not working...

    Quote Originally Posted by Astronomy View Post
    Hello again,

    today i had the time to solve this problem with your suggestions ...

    Thanks so much. This is the only explicit example I found on line that explain what's going on with scrollarea created with UI not showing properly issue. Solve my doubt and improve my skill. Thanks again.

Similar Threads

  1. Replies: 5
    Last Post: 19th March 2010, 19:13
  2. transparent QScrollArea and blurry scrolling
    By titanandrews in forum Qt Programming
    Replies: 2
    Last Post: 17th January 2010, 01:35
  3. QScrollArea scrolling down not up
    By ntp in forum Qt Programming
    Replies: 5
    Last Post: 20th August 2008, 18:23
  4. Scrolling bar problem in QScrollArea
    By YuriyRusinov in forum Qt Programming
    Replies: 1
    Last Post: 4th February 2007, 22:22
  5. Replies: 2
    Last Post: 8th October 2006, 21:14

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.