Results 1 to 5 of 5

Thread: Qt 4.7 + QGLWidget causes lock up when window resizes/moves

  1. #1
    Join Date
    Apr 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qt 4.7 + QGLWidget causes lock up when window resizes/moves

    I recently just got Qt 4.7 (from Qt 4.6.1). Ever since then any application that I create a QGLWidget for are causing that application to lock up whenever I move/resize the main window. When I resize, the mouse stays on the resize cursor. When I try to move the window nothing happens. In both cases my machine locks up and I have to ctrl+alt+delete to get out of this state. I tested the sample example below with Qt 4.6.1 that I had before and this works without any problems so it's something new with Qt 4.7. Any help would be greatly appreciated. Thanks!


    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6.  
    7. myTimer = new QTimer(this);
    8.  
    9. myGlWidget = new QGLWidget(this);
    10.  
    11. connect(myTimer, SIGNAL(timeout()), this, SLOT(updateRender()));
    12.  
    13. myTimer->start(0);
    14. }
    15.  
    16. void MainWindow::updateRender()
    17. {
    18. if(myGlWidget)
    19. {
    20. myGlWidget->updateGL();
    21. }
    22. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt 4.7 + QGLWidget causes lock up when window resizes/moves

    This:
    Qt Code:
    1. myGlWidget = new QGLWidget(this);
    2.  
    3. connect(myTimer, SIGNAL(timeout()), this, SLOT(updateRender()));
    4.  
    5. myTimer->start(0);
    To copy to clipboard, switch view to plain text mode 

    will cause your GL widget to update continuously( after other events have been processed).
    Why do you use such a construct in the first place?
    Are you sure this is what you want?
    This could also explain the behavior you are experiencing, depending on how you implemented updateGL().

    I tested the sample example below with Qt 4.6.1 that I had before and this works without any problems so it's something new with Qt 4.7.
    If you did something wrong before which 4.6 somehow allowed, the fact 4.7 is not allowing it doesn't necessarily mean the problem is with the new Qt version (more like with the older version).
    Last edited by high_flyer; 18th April 2011 at 09:28.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Apr 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt 4.7 + QGLWidget causes lock up when window resizes/moves

    Thank you for your reply. Yes I do realize that this will cause the GL widget to update continuously, which is what I want as I am creating an animation. Is there a better way to do this?

    Also, in the example I give I am doing nothing but creating a Qt QGLWidget, not a derived one. So I am not re-implementing updateGL() or anything, I'm just using pure Qt code. I found that if I changed the timer to delay for about 20 msecs then the application no longer locks up, so I'm guessing that Qt doesn't really want you use a timer in this fashion anymore as it doesn't properly get a chance to handle the other events. It wasn't just 4.6 that this worked for I've done this with 4.2 up until now.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt 4.7 + QGLWidget causes lock up when window resizes/moves

    Yes I do realize that this will cause the GL widget to update continuously, which is what I want as I am creating an animation.
    But you are updating your widget even when no animation is going on...
    You should start the timer when you want to animate something, and stop it when the animation is finished.
    Also, a 0 timer is a bit extreme for animation, the human eye will perceive a smooth motion with 24 fps, which is about 40ms.
    With a 0 timer you are making your application use CPU cycles that it doesn't need.

    If you make a simple project which only has a QGLWidget and a 0 timer, and it still locks, you might want to register a bug, with the code for reproducing it.
    However, at least based on the code you posted, I can't explain why you experience a lockup.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Apr 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt 4.7 + QGLWidget causes lock up when window resizes/moves

    The animation, the sun in my case, should never stop until the program closes. With the previous versions, 4.2-4.6, I was getting 60fps but now I have to use the 20ms delay and I get 45fps. Yes I realize that this is still acceptable to perceive a smooth animation but it's kind of a bummer that I'm not able to render as fast as I use to. I can only imagine that if I had a more complex scene to render that I would lose even more fps. The sample code I posted does just have a QGLWidget and a 0 timer, so I'll go with that to register a bug. Thanks for helping.

Similar Threads

  1. How to render context of QGLWidget, outside of the window
    By KnufflPuffl in forum Qt Programming
    Replies: 1
    Last Post: 28th December 2010, 21:41
  2. QWidget/QGlwidget ( + window opacity )
    By medved6 in forum Qt Programming
    Replies: 0
    Last Post: 5th October 2010, 06:14
  3. Replies: 1
    Last Post: 2nd July 2010, 19:47
  4. problem: Window moves on click when maximized
    By Toshikazu in forum Qt Programming
    Replies: 3
    Last Post: 30th January 2010, 22:22
  5. Transparent window with QGLWidget
    By ultr in forum Qt Programming
    Replies: 4
    Last Post: 28th April 2008, 07:01

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.