PDA

View Full Version : problem adding QGlwidget into a QGraphicsScene



gch0214
15th May 2012, 09:16
I have a class which was inherited from QGLWidget

codes here:


class NeHeWidget : public QGLWidget
{
Q_OBJECT

public:

NeHeWidget( QWidget* parent = 0, const char* name = 0, bool fs = false );
~NeHeWidget();

protected:

void initializeGL();
void paintGL();
void resizeGL( int width, int height );

void keyPressEvent( QKeyEvent *e );

protected:

bool fullscreen;
GLfloat rTri;
GLfloat rQuad;

};

so I tried to place this OpenGl part into a window , which I can see the picture created by OpenGL on the left side , and buttons on the right side
like in this picture:
7720

I thought this class was inherited from QGLWidget

so I guess I can use this :

NeHeWidget w( 0, 0, fs );
QGraphicsScene scene;
QGraphicsProxyWidget *proxy = scene.addWidget(w,Qt::WindowFlags);

but it doesn't work.:confused:
the compiler says the error is:
expected primary-expression before ')' token

So how do I fix it?
if I didn't placed in the QGraphicsScene , it works well

or is there any way to do what was shown in the attachment?

thank you in advance!
THANKS A LOT

amleto
15th May 2012, 10:04
scene.addWidget(w,Qt::WindowFlags);
^^ this doesnt make sense


pick any value (or union of values from here)
http://qt-project.org/doc/qt-4.8/qt.html#WindowType-enum


you cant pass a type name as an argument...

thats like doing this:



void foo(int x)
{
}

int main()
{
foo(int);
}

Which, hopefully looks a bit daft to you.

gch0214
15th May 2012, 10:45
thanks for your reply, I finally achieved it