Results 1 to 8 of 8

Thread: Scroll area on right side of main window

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2009
    Posts
    56
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Scroll area on right side of main window

    I want to add a scroll area to the right side of my main window, the same as "Object Inspector" in QT Designer.

    Every other line should be slightly darker
    Each line will contain one text element
    You can drag the left edge to make it bigger or smaller.
    You can turn the scroll area on or off with a checkbox from the menu

    I'm having a hard time understanding which elements to put down to do this. Would this be a Horizontal layout? I can't get it to attach to the right side of the window. And when I put down a Scroll area container, what goes inside? And lastly, how do I make every other line slightly darker, like Object Inspector does?

    Sorry for the dumb questions. I've reread the part on the layouts several times but it hasn't made sense to me so far.

  2. #2
    Join Date
    Feb 2008
    Posts
    98
    Thanks
    2
    Thanked 24 Times in 24 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Scroll area on right side of main window

    The Object Inspector is a QDockWidget. You just need to add a QDockWidget to your main window. To insert a menu action that toggles the dock on or off, you may use QDockWidget::toggleViewAction().

    The list of objects in the Object Inspector is a QTreeView. You will need to implement a model for it. To make every even line darker, you may set alternatingRowColors to true.
    Last edited by victor.fernandez; 27th August 2009 at 08:01. Reason: added alternatingRowColors

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

    rakkar (27th August 2009)

  4. #3
    Join Date
    Aug 2009
    Posts
    56
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Re: Scroll area on right side of main window

    I added the dock view, and an item based list view inside. How do I make the item based list view always take up the entire area of the dock view? Thanks in advance.

  5. #4
    Join Date
    Jan 2006
    Location
    Innsbruck, Austria
    Posts
    62
    Thanks
    10
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Scroll area on right side of main window

    In Qt Designer, you may add a layout (e.g. a vertical layout). If you're adding the view by code, use QDockWidget::setWidget().

  6. #5
    Join Date
    Aug 2009
    Posts
    56
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Re: Scroll area on right side of main window

    Is the QListWidget supposed to be a child of verticalLayout in ObjectInspector? If it's not a child the layout doesn't seem to do anything. If the QListWidget is a child, it doesn't fill the layout. It's like 1/4 of the layout, only in the center.
    Attached Images Attached Images

  7. #6
    Join Date
    Feb 2008
    Posts
    98
    Thanks
    2
    Thanked 24 Times in 24 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Scroll area on right side of main window

    Just follow this procedure:

    - Create a QMainWindow in Qt Designer.
    - Add a dock widget.
    - Add a QListWidget inside of the dock widget.
    - Select the dock widget by clicking on it.
    - Click the Form menu - Layout vertically.
    Voièla!

    Now you can resize the dock widget. The list widget will take the whole space.
    Attached Images Attached Images

  8. The following user says thank you to victor.fernandez for this useful post:

    rakkar (28th August 2009)

  9. #7
    Join Date
    Aug 2009
    Posts
    56
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Re: Scroll area on right side of main window

    Thanks. If I want to put a label above the list widget, the label takes up half of the vertical area of the dock widget. How do I get the label to only take up the necessary size to show it? I tried changing size policy to minimum but it doesn't do anything.

  10. #8
    Join Date
    Jan 2006
    Location
    Innsbruck, Austria
    Posts
    62
    Thanks
    10
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Scroll area on right side of main window

    Make sure the vertical size policy of the label is Preferred and the vertical size policy of the QListWidget is Expanding or MinimumExpanding.

Similar Threads

  1. Replies: 2
    Last Post: 9th August 2009, 22:08
  2. adding items in scroll area dynamically
    By Ezhil in forum Qt Programming
    Replies: 5
    Last Post: 22nd May 2009, 16:33
  3. Adding scroll bars to a main window
    By dougab in forum Newbie
    Replies: 9
    Last Post: 25th December 2007, 20:27
  4. minimizing main window
    By eric in forum Qt Programming
    Replies: 4
    Last Post: 28th November 2007, 16:54
  5. cannot make a main window modal
    By Dark_Tower in forum Qt Programming
    Replies: 12
    Last Post: 23rd March 2006, 10:21

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.