Results 1 to 10 of 10

Thread: QGLWidget trouble

  1. #1
    Join Date
    Jul 2009
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QGLWidget trouble

    Hi

    I created a simple GUI with a splitter as a main widget. The splitter holds 3 widgets : A tab widget, a QGLWidget and a QLabel to display image files. Initially the QLabel is hidden and the QGLWidget is displayed.
    My problem is this : When I switch between the QGLWidget and the QLabel ( using slots to hide / show to switch between them), my QGLWidget does not show any graphics after switching. I have tried refreshing, update etc. Can someone tell me what is happening?

    Thanks

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGLWidget trouble

    Can you call :
    Qt Code:
    1. yourGLWidget->updateGL()
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jul 2009
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Re: QGLWidget trouble

    I tried that. The QGLWidget is still blank.

  4. #4
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Smile Re: QGLWidget trouble

    Maybe you have your "camera" (or modelview matrix) in a wrong place. Maybe your projection matrix is wrong...

    What do you see without any other components? Is it working in that case?

  5. #5
    Join Date
    Jul 2009
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGLWidget trouble

    Quote Originally Posted by ricardo View Post
    Maybe you have your "camera" (or modelview matrix) in a wrong place. Maybe your projection matrix is wrong...

    What do you see without any other components? Is it working in that case?
    The graphics works properly when I load a model but when I switch to another widget ( myGLWidget->hide (); myLabel->show (); ) and then switch back to the QGLWidget ( myGLWidget->show (); myLabel->hide (); ); the QGLWidget does not display what was being displayed earlier.

    Is there something happening that I am not taking care of?

  6. #6
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGLWidget trouble

    Can we see your code?

  7. #7
    Join Date
    Jul 2009
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGLWidget trouble

    The actual code is a little long but here is pseudo code :

    myWindow::QMainWindow -> main window

    mySplitter::QSplitter -> central widget to myWindow

    myWidget::QWidget -> Widget 1

    myGLWidget::QGLWidget -> Widget 2 // Shown by default

    myLabel::QLabel -> Widget 3 // Hidden by default

    // Add Widget 1, Widget 2. Widget 3 to mySplitter

    // myWidget has a QTabWidget as a child widget with 2 tabs. On the tab change signal, I have a slot based on the index which does this :

    if ( index == 0 ) {
    myGLWidget->show ();
    myLabel->hide ();
    }

    if ( index == 1 ) {
    mGLWidget->hide();
    myLabel->show ();
    }

    //-------------------------------------------------------------------------------------------
    On running the app, it loads a model and the myGLWidget displays graphics properly, but when I switch between tabs, on switching back to myGLWidget the graphics remains blank.

  8. #8
    Join Date
    Apr 2009
    Posts
    132
    Thanks
    67
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QGLWidget trouble

    Can I see your methods paintGL and resizeGL and and how do you manage GL_PROJECTION and GL_MODELVIEW matrices?

  9. #9
    Join Date
    Aug 2008
    Location
    Algarve, Portugal
    Posts
    288
    Thanks
    23
    Thanked 32 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: QGLWidget trouble

    Are you working on windows or linux ? Is the behavior identical in both plataforms ?
    There are some limitations on windows plataform when you have several qglwidgets, just read carefully the documentation. I had a class with 3 qglwidget who would not display in windows but worked fine in linux
    Last edited by john_god; 30th July 2009 at 22:55.

  10. #10
    Join Date
    Jul 2009
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGLWidget trouble

    Quote Originally Posted by john_god View Post
    Are you working on windows or linux ? Is the behavior identical in both plataforms ?
    There are some limitations on windows plataform when you have several qglwidgets, just read carefully the documentation. I had a class with 3 qglwidget who would not display in windows but worked fine in linux
    Yes the behaviour is identical on both platforms and there is only one QGLWidget.
    I put some trace comments in the graphics code and it has thrown up some interesting output.
    When the QGLWidget is displayed again, it calls the resizeGL function and while setting up my projection matrix with previously stored values, the near and far values are getting screwed up. So does some other camera parameter values. I am wondering if this is somehow related to a QGLContext problem.

Similar Threads

  1. Switching QGLWidget maintainer
    By seim in forum Qt Programming
    Replies: 1
    Last Post: 15th July 2009, 12:36
  2. Replies: 1
    Last Post: 23rd April 2009, 09:05
  3. Replies: 1
    Last Post: 21st November 2008, 07:00
  4. Replies: 4
    Last Post: 7th May 2008, 00:01
  5. QGLWidget resize problem.
    By anderl in forum Qt Programming
    Replies: 2
    Last Post: 22nd January 2008, 08:57

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.