#include <QtGui>
#include "glwidget.h" // from <qt-dir>/examples/opengl/hellogl/glwidget.*
// QGraphicsView that uses a GLWidget as its viewport
{
public:
{
mpGLWidg = new GLWidget(NULL);
setViewport(mpGLWidg);
};
protected:
{
mpGLWidg->updateGL();
};
private:
GLWidget* mpGLWidg; // use GLWidget class from <qt-dir>/examples/opengl/hellogl/glwidget.*
// it depends on <qt-dir>/examples/opengl/shared/qtlogo.*
};
int main(int argc, char *argv[])
{
GLGraphicsView gView(&scene);
// comment this line out, and the logo will appear:
scene.
addEllipse(QRectF(10,
20,
30,
40),
QPen(Qt
::green),
QBrush(Qt
::SolidPattern));
gView.resize(800,600);
gView.show();
int ret = app.exec();
return ret;
}
#include <QtGui>
#include "glwidget.h" // from <qt-dir>/examples/opengl/hellogl/glwidget.*
// QGraphicsView that uses a GLWidget as its viewport
class GLGraphicsView : public QGraphicsView
{
public:
GLGraphicsView(QGraphicsScene * scene, QWidget * parent = 0 ) : QGraphicsView(scene, parent)
{
mpGLWidg = new GLWidget(NULL);
setViewport(mpGLWidg);
};
protected:
void drawBackground(QPainter *p, const QRectF &r)
{
mpGLWidg->updateGL();
QGraphicsView::drawBackground(p, r);
};
private:
GLWidget* mpGLWidg; // use GLWidget class from <qt-dir>/examples/opengl/hellogl/glwidget.*
// it depends on <qt-dir>/examples/opengl/shared/qtlogo.*
};
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QGraphicsScene scene;
GLGraphicsView gView(&scene);
// comment this line out, and the logo will appear:
scene.addEllipse(QRectF(10, 20, 30, 40), QPen(Qt::green), QBrush(Qt::SolidPattern));
gView.resize(800,600);
gView.show();
int ret = app.exec();
return ret;
}
To copy to clipboard, switch view to plain text mode
Bookmarks