Results 1 to 5 of 5

Thread: Using QScrollArea

  1. #1
    Join Date
    Jan 2006
    Location
    Edmonton, Canada
    Posts
    101
    Thanks
    13
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Using QScrollArea

    Hi there. I am new to Qt and was hoping to get some advice.

    I am trying to create a custom widget that consists of multiple QTableViews, organized using a QVBoxLayout. Since this widget could potentially grow quite large, I would like to be able to specify a size for the control and be able to scroll horizontally/vertically as required to view the QTableViews.

    I am encountering some difficulties implementing this, however, and am getting a little frustrated with the lack of information available regarding Qt4's QScrollArea. If there is any info regarding this topic on the internet, I would appreciate a link to it.

    More specifically, I have a few questions about my design and implementation:
    1. Is it better to put the widget in a QScrollArea, or to have the widget inherit from QScrollArea/QAbstractScrollArea
    2. Is there any documentation regarding the use of QSizeHint and QSizePolicy? I have read the official documentation but the use of these is still not clear to me.


    Any info is appreciated.

    Jimmy

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

    Default Re: Using QScrollArea

    Try setting the vbox layout to a widget and setting it to the scroll area. No need to inherit scroll area in this case..

  3. #3
    Join Date
    Jan 2006
    Location
    Edmonton, Canada
    Posts
    101
    Thanks
    13
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Using QScrollArea

    That sounds promising. Could you please be a little more explicit, though? I don't quite follow your meaning here.

    Thanks.

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

    Default Re: Using QScrollArea

    Something like this:
    Qt Code:
    1. QWidget* widget = new QWidget;
    2. widget->setLayout(vbox);
    3. scrollarea->setWidget(widget);
    To copy to clipboard, switch view to plain text mode 

    The vbox layout contains all tables and so on and is able to count the needed size and works nicely in a scroll area.. Just test and see how perfectly it works

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

    Jimmy2775 (2nd March 2006)

  6. #5
    Join Date
    Jan 2006
    Location
    Edmonton, Canada
    Posts
    101
    Thanks
    13
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Using QScrollArea

    Oh sweet - thanks jpn. Now this is starting to look the way I'd like.

    A further question...

    I want to set the height of the QTableView to be the height of its contents, but the only way I can see to do this is to loop through all the rows and add each rowHeight. Is there a more efficient way to do this?

Similar Threads

  1. Replies: 1
    Last Post: 13th September 2008, 11:00
  2. Dynamic updates of a QWidget in a QScrollArea
    By plamkata in forum Qt Programming
    Replies: 2
    Last Post: 20th July 2008, 23:45
  3. QScrollArea
    By sabeesh in forum Qt Programming
    Replies: 7
    Last Post: 2nd November 2007, 10:33
  4. QScrollArea and resizing
    By rarefluid in forum Qt Programming
    Replies: 8
    Last Post: 22nd July 2007, 14:18
  5. Replies: 2
    Last Post: 8th October 2006, 20: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.