Results 1 to 6 of 6

Thread: How to display 2 widgets on the same space?

  1. #1
    Join Date
    Jul 2011
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default How to display 2 widgets on the same space?

    I have this main window on which I would like to put 2 widgets on the same space, i.e. when the user clicks a button then one of the widgets should come up front and the other be hidden and then change places when clicking another button.

    My Widget are of different types: one is a QGLWidget and the other one is a QGraphicsView.

    How could I put these 2 widgets on the same place?

  2. #2
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to display 2 widgets on the same space?

    Hi,

    If I understand correctly. You can place bot items in the same x,y position. Then one of them can have setVisible(false) from the start. Then with the button you can set one to setVisible(true) and the other setVisible(false), the other button can do the inverse process false,true.

  3. #3
    Join Date
    Jul 2011
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to display 2 widgets on the same space?

    yes. something like that. but then how could I set the layout of the main window? because apart from these 2 widgets which should be on the top half of the main window I also have some widgets on the bottom half.

  4. #4
    Join Date
    Aug 2009
    Location
    Belgium
    Posts
    310
    Thanks
    10
    Thanked 31 Times in 25 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to display 2 widgets on the same space?

    Why don't you just use a stacked widget to put the 2 upper widgets in ? Then you don't have to do any 'tricks', just select the other page of the stacked widget.

    And the other widgets can easily be arranged below this stacked widget, maybe grouped into a frame or groupbox.

    Best regards,
    Marc

  5. #5
    Join Date
    Jul 2011
    Posts
    16
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to display 2 widgets on the same space?

    really good idea with the stacked widget. it works perfectly now for what i want it to do. thanks.

  6. #6
    Join Date
    Sep 2008
    Location
    Poland
    Posts
    80
    Thanks
    4
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: How to display 2 widgets on the same space?

    Read the Assistant about QStackedLayout class

Similar Threads

  1. space between widgets in qgridlayout
    By demol in forum Qt Programming
    Replies: 2
    Last Post: 6th January 2010, 20:07
  2. Replies: 1
    Last Post: 26th July 2009, 15:08
  3. Replies: 0
    Last Post: 1st October 2008, 16:21
  4. Replies: 6
    Last Post: 3rd January 2008, 09:33
  5. linking user space and kernel space programs with qmake
    By zielchri in forum Qt Programming
    Replies: 9
    Last Post: 8th March 2006, 23:11

Tags for this Thread

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.