View Full Version : QGLWidget doenst work on Mac
john_god
9th October 2010, 17:09
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:
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent (QMouseEvent * event);
void mouseMoveEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent * event );
bool event(QEvent *event);
void keyPressEvent(QKeyEvent *event);
void timerEvent(QTimerEvent *event);
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 ?
wysota
9th October 2010, 19:15
Do you always call the base class implementation?
john_god
9th October 2010, 22:42
I call a derived class GLGraph3D_fxy:
class Graph3D_Base_GLWidget : public QGLWidget
{
Q_OBJECT
public:
Graph3D_Base_GLWidget();
~Graph3D_Base_GLWidget();
void initializeGL();
virtual void paintGL();
void axis3D();
void resizeGL(int width, int height);
void AutoRotate();
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent (QMouseEvent * event);
void mouseMoveEvent(QMouseEvent *event);
void wheelEvent(QWheelEvent * event );
bool event(QEvent *event); //function causing the problem
void keyPressEvent(QKeyEvent *event);
void timerEvent(QTimerEvent *event);
...
};
class GLGraph3D_fxy : public Graph3D_Base_GLWidget
{
Q_OBJECT
public:
GLGraph3D_fxy();
~GLGraph3D_fxy();
virtual void paintGL();
...
void contextMenuEvent(QContextMenuEvent * event ) ;
...
};
....
bool Graph3D_Base_GLWidget::event(QEvent *event)
{
if (event->type() == QEvent::WindowDeactivate)
{
if (TimerRotate != 0)
{
killTimer(TimerRotate);
TimerRotate = 0;
}
return true;
}
return QWidget::event(event);
}
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
wysota
10th October 2010, 10:12
So what is the contents of your event() implementation?
john_god
10th October 2010, 11:30
Sorry I didnt explain me. I wrote event() but is the event(QEvent *event) wich is causing the problem.
bool Graph3D_Base_GLWidget::event(QEvent *event)
{
if (event->type() == QEvent::WindowDeactivate)
{
if (TimerRotate != 0)
{
killTimer(TimerRotate);
TimerRotate = 0;
}
return true;
}
return QWidget::event(event);
}
I only have this implemented in the base class
wysota
10th October 2010, 15:47
Why do you prevent Qt from handling WindowDeactivate on its own?
john_god
10th October 2010, 17:34
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
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.