PDA

View Full Version : problem with displaying QGLWidget in QWidget made in desinger



yasirsaleem
9th March 2011, 13:19
hi dear,
I am using qt 4.7.1 and qt-creator 2.0.1. I have made a qglwidget.h and qglwidget.cpp. Then I made a widget in designer, right click it, selected promote to, then in base class I select "QWidget", in Promoted class name I wrote QGLWidget and in header file I wrote qglwidget.h
Now the problem is that how can I display my qglwidet.cpp code in the widget, which I made through designer. When I run my project the widget (to which I promote qtwidget) is displaying a black screen.
Kindly tell me that how can I display my code in that widget.

Thank you very much

stampede
9th March 2011, 13:39
Have you read the QGLWidget docs (http://doc.qt.nokia.com/4.7-snapshot/qglwidget.html) ? You need to put your OpenGL code in paintGL(), initializeGL() and resizeGL() methods (there is an example in documentation).

yasirsaleem
9th March 2011, 14:02
yes, I have already written my code in these functions. And if I create a new instance of qglwidet instance then it works fine. The problem is that how should I show it in widget made in desinger

stampede
9th March 2011, 14:38
in Promoted class name I wrote QGLWidget
Ok, so this is the problem - you need to provide your WidgetClassName instead of QGLWidget, because now you are adding default QGLWidget to your ui.

I have made a qglwidget.h and qglwidget.cpp
I'd also suggest changing your file names.

yasirsaleem
9th March 2011, 18:46
Ok, so this is the problem - you need to provide your WidgetClassName instead of QGLWidget, because now you are adding default QGLWidget to your ui.

I'd also suggest changing your file names.

Thank you so much. My problem has been solved by changing my filenames.