Problem in compiling, QGraphicsScene::setActiveWindow() not accepting a QGLWidget subclass
-
I had a QGLWidget subclass as the graphics class, which I now want to be used as a single window in a QGraphicsScene in order to accomodate the menu.
It looks like this:
GLWindow class
@
#ifndef GLWINDOW_H
#define GLWINDOW_H#include <things>
class GLWindow : public QGLWidget , public QGraphicsProxyWidget // tried QGraphicsWidget too.
{
Q_OBJECT
public:
GLWindow(QWidget *parent = 0);
~GLWindow();void resizeGL(int width, int height); void initializeGL(); void paintGL();
// Other functions, signals/slots etc.
// .............................
};
#endif // GLWINDOW_H@main.cpp
@
#include <QtGui/QApplication>
#include "glwindow.h"
#include <QDebug>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsProxyWidget>int main(int argc, char *argv[])
{
QApplication a(argc, argv);
GLWindow w;// ...............THIS WORKS.........................
//#ifndef Q_WS_MAEMO_5
// w.showMaximized();
//#else
// w.showFullScreen();
//#endif//...............But This Does not...................
QGraphicsScene scene;
scene.setActiveWindow(w);
//scene.setActiveWindow((dynamic_cast<QGraphicsProxyWidget*>)(w)); // ... did not work
QGraphicsView view(&scene);
view.showMaximized();return a.exec();
}@
I understand that the "setActiveWindow()":http://doc.qt.nokia.com/4.8-snapshot/qgraphicsscene.html#setActiveWindow method requires a QGraphicsWidget object, but I still am not able to compile after subclassing QGraphiscWidget (and QGraphicsProxyWidget). Trying to dynamic_cast my QGLWidget subclass did not work either. The error is something like:
- ..\main.cpp:22: error: no matching function for call to 'QGraphicsScene::setActiveWindow(GLWindow&)'
I also tried modifying the constructor declaration for GLWindow class as:
@GLWindow(QWidget *parent = 0, QGraphicsProxyWidget *parent = 0);@but still no progress. (I dont think I should be doing this, but there was no harm in trying!)
Appreciate any help from someone who already has done this. Any comments are welcome.
-
setActiveWindow is requiring a pointer and not a reference see the link you have provided.
try this:
@
QGraphicsScene scene;
scene.setActiveWindow(&w);
//scene.setActiveWindow((dynamic_cast<QGraphicsProxyWidget*>)(w)); // ... did not work
@