Results 1 to 7 of 7

Thread: QGLWidget doenst work on Mac

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

    Default QGLWidget doenst work on Mac

    I have a QGLWidget wich work nicely on Windows and Linux, shows a qglwidget with black ground color and some graphs, but fails on Mac, I only get a blank windows. I have events like:

    Qt Code:
    1. void mousePressEvent(QMouseEvent *event);
    2. void mouseReleaseEvent (QMouseEvent * event);
    3. void mouseMoveEvent(QMouseEvent *event);
    4. void wheelEvent(QWheelEvent * event );
    5. bool event(QEvent *event);
    6. void keyPressEvent(QKeyEvent *event);
    7. void timerEvent(QTimerEvent *event);
    To copy to clipboard, switch view to plain text mode 

    event() is causing the problem. If I remove it it will work. If I use it, even without any code in it, the blank QGLWidget will show. Either case, the program compiles and runs without errors. I looked for mac qglwidget limitations but didnt find nothing related to this. Any ideas ?
    __________________________________________________
    My projects: calculator MathGraphica ; SuperEpicMegaHero game ; GooglePlay ; bitbucket ; github
    Like my projects ? Buy me a kofi

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QGLWidget doenst work on Mac

    Do you always call the base class implementation?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: QGLWidget doenst work on Mac

    I call a derived class GLGraph3D_fxy:


    Qt Code:
    1. class Graph3D_Base_GLWidget : public QGLWidget
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. Graph3D_Base_GLWidget();
    7. ~Graph3D_Base_GLWidget();
    8.  
    9. void initializeGL();
    10. virtual void paintGL();
    11. void axis3D();
    12.  
    13.  
    14. void resizeGL(int width, int height);
    15.  
    16. void AutoRotate();
    17.  
    18.  
    19. void mousePressEvent(QMouseEvent *event);
    20. void mouseReleaseEvent (QMouseEvent * event);
    21. void mouseMoveEvent(QMouseEvent *event);
    22. void wheelEvent(QWheelEvent * event );
    23. bool event(QEvent *event); //function causing the problem
    24. void keyPressEvent(QKeyEvent *event);
    25. void timerEvent(QTimerEvent *event);
    26. ...
    27.  
    28. };
    29.  
    30. class GLGraph3D_fxy : public Graph3D_Base_GLWidget
    31. {
    32. Q_OBJECT
    33.  
    34. public:
    35. GLGraph3D_fxy();
    36. ~GLGraph3D_fxy();
    37.  
    38. virtual void paintGL();
    39.  
    40. ...
    41. void contextMenuEvent(QContextMenuEvent * event ) ;
    42. ...
    43.  
    44.  
    45. };
    46.  
    47. ....
    48.  
    49. bool Graph3D_Base_GLWidget::event(QEvent *event)
    50. {
    51.  
    52. if (event->type() == QEvent::WindowDeactivate)
    53. {
    54. if (TimerRotate != 0)
    55. {
    56. killTimer(TimerRotate);
    57. TimerRotate = 0;
    58. }
    59.  
    60. return true;
    61. }
    62.  
    63. return QWidget::event(event);
    64.  
    65. }
    To copy to clipboard, switch view to plain text mode 

    I also just notice if I resize the blank window it will turn black and display the graphs correctly. I'm guessing I have some broken code, or some initialization issue, but it puzzles me that it works good on windows and linux
    __________________________________________________
    My projects: calculator MathGraphica ; SuperEpicMegaHero game ; GooglePlay ; bitbucket ; github
    Like my projects ? Buy me a kofi

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QGLWidget doenst work on Mac

    So what is the contents of your event() implementation?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: QGLWidget doenst work on Mac

    Sorry I didnt explain me. I wrote event() but is the event(QEvent *event) wich is causing the problem.

    Qt Code:
    1. bool Graph3D_Base_GLWidget::event(QEvent *event)
    2. {
    3.  
    4. if (event->type() == QEvent::WindowDeactivate)
    5. {
    6. if (TimerRotate != 0)
    7. {
    8. killTimer(TimerRotate);
    9. TimerRotate = 0;
    10. }
    11.  
    12. return true;
    13. }
    14.  
    15. return QWidget::event(event);
    16. }
    To copy to clipboard, switch view to plain text mode 

    I only have this implemented in the base class
    __________________________________________________
    My projects: calculator MathGraphica ; SuperEpicMegaHero game ; GooglePlay ; bitbucket ; github
    Like my projects ? Buy me a kofi

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QGLWidget doenst work on Mac

    Why do you prevent Qt from handling WindowDeactivate on its own?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: QGLWidget doenst work on Mac

    Hi Wysota. My mistake. I removed the line with "return true;" so Qt could handle it.
    Anyway I found the problem, I was returning QWidget::event(event) instead of returning QGLWidget::event(event);
    Dont know why this worked for windows and linux and not on mac, but it was wrong for all.
    It works now. thanks
    __________________________________________________
    My projects: calculator MathGraphica ; SuperEpicMegaHero game ; GooglePlay ; bitbucket ; github
    Like my projects ? Buy me a kofi

Similar Threads

  1. QGLWidget and VBO
    By kaszewczyk in forum Newbie
    Replies: 1
    Last Post: 6th May 2010, 11:04
  2. Replies: 2
    Last Post: 13th December 2009, 21:27
  3. QGLWidget, keyPressEvent does not work
    By ricardo in forum Qt Programming
    Replies: 7
    Last Post: 3rd July 2009, 11:28
  4. Can not use QGLWidget.
    By Teuniz in forum Installation and Deployment
    Replies: 3
    Last Post: 25th September 2007, 01:27
  5. QGLWidget bug
    By Wizard in forum Qt Programming
    Replies: 11
    Last Post: 31st August 2007, 12:23

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.