Results 1 to 6 of 6

Thread: QGridLayout

  1. #1
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Question QGridLayout

    I am creating a couple QGLWidgets and displaying them on top of each other. I mean they are above each other on the screen and not actually on top of one another. I use a QGridLayout to align these into 1 column by 'n' rows. I want to be able to double click on any one of these QGLWidgets and allow it to fill the whole screen and then double-click on the full-screen QGLWidget and go back to the previous view of displaying multiple QGLWidgets. I have the slot and signal working correctly because when I double click onto the QGLWidget, I have qDebug statements print out lines before issuing the signal and then inside the slot. But the problem seems to be coming in my handling of the QGridLayout. I create a for-loop that essentially looks like this:

    Qt Code:
    1. // Written in pseudo-code as the code is on another machine
    2. for( int i = 0 ; i < numQGLWidgets ; i++ )
    3. {
    4. GridLayout->removeWidget( QListOfQGLWidgets[i] );
    5. }
    To copy to clipboard, switch view to plain text mode 

    To this point, I believe there should be no widgets remaining in the QGridLayout. Then I go back through the list of QGLWidgets and when it matches the one that sent the signal which is passed in as an argument, I call addWidget like this:

    Qt Code:
    1. //Again in psuedo-code
    2. for( int i = 0 ; i < numQGLWidgets ; i++ )
    3. {
    4. if( QListOfQGLWidgets[i] == signalEmitter )
    5. {
    6. GridLayout->addWidget( QListOfQGLWidgets[i] );
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

    But if I click on the first QGLWidget, the OpenGL drawing doubles in size and everything looks like it wants to draw on the entire window, but when you look at the middle of the screen, the second QGLWidget still appears and is still accessible to move and scale. So my question is how do I actually get these other QGLWidgets to disappear and allow the double-clicked QGLWidget to appear over the entire allotted space? Thanks!

  2. #2
    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: QGridLayout

    Call QWidget::hide() on all other widgets.

  3. #3
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Cool Re: QGridLayout

    Would hiding these other QGLWidgets cause flicker to occur by hiding them? Would it be more efficient or better to just create a second layout and just call the frame's setLayout() with the new layout? Also, is it just me or should removeWidget( ) actually remove the widget from the layout? If not, what does this function actually do since it does not appear to remove any widgets? Thanks again!

  4. #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: QGridLayout

    Quote Originally Posted by ToddAtWSU
    Would hiding these other QGLWidgets cause flicker to occur by hiding them?
    No, it shouldn't cause flicker. Of course it depends how many widgets you actually have there

    quote]Would it be more efficient or better to just create a second layout and just call the frame's setLayout() with the new layout?[/quote]
    It depends whether you want to show all other widgets again. If so, then it's easier to hide them.

    Also, is it just me or should removeWidget( ) actually remove the widget from the layout?
    Yes, it should remove a widget from a layout. Can we see the code you wrote to do it?

  5. #5
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGridLayout

    Quote Originally Posted by ToddAtWSU
    Also, is it just me or should removeWidget( ) actually remove the widget from the layout? If not, what does this function actually do since it does not appear to remove any widgets? Thanks again!
    Yes, the widget will be removed from the layout, but that does not mean that it is removed from the screen. You have to call hide() to do that.

    In general, what you are trying to achieve should be easy to do just by causing hide() and show() on the relevant widgets. You should not have to manipulate the layout at all.
    Save yourself some pain. Learn C++ before learning Qt.

  6. The following user says thank you to Chicken Blood Machine for this useful post:

    bits (30th June 2006)

  7. #6
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QGridLayout

    Okay, thanks for the help. I have it working now by using hide() and show(). But I will remember that removeWidget() removes it from the layout but not from the screen. Thanks!

Similar Threads

  1. QPixmap and QGridLayout
    By Talon_Karrde in forum Qt Programming
    Replies: 5
    Last Post: 22nd February 2006, 12:27

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.