#include <QApplication>
#include <QGLWidget>
#include <QMainWindow>
#include <QSplitter>
#include <QTextEdit>
{
public:
protected:
virtual void paintGL();
virtual void resizeGL(int, int) { }
};
void GLWidget :: paintGL()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.5f,0.5f,0.0f);
glBegin(GL_QUADS);
glVertex3f(-1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glEnd();
}
int main(int argc, char **argv)
{
mainwindow.setFixedSize(1000,600);
splitter->addWidget(new GLWidget());
mainwindow.setCentralWidget(splitter);
mainwindow.show();
return app.exec();
}
#include <QApplication>
#include <QGLWidget>
#include <QMainWindow>
#include <QSplitter>
#include <QTextEdit>
class GLWidget : public QGLWidget
{
public:
GLWidget(QWidget *parent = 0) : QGLWidget(parent) {}
GLWidget(const QGLFormat &format, QWidget *parent = 0, const QGLWidget *shareWidget = 0, Qt::WindowFlags f = 0) :
QGLWidget(format, parent, shareWidget, f){}
protected:
virtual void paintGL();
virtual void resizeGL(int, int) { }
};
void GLWidget :: paintGL()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.5f,0.5f,0.0f);
glBegin(GL_QUADS);
glVertex3f(-1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glEnd();
}
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QMainWindow mainwindow;
mainwindow.setFixedSize(1000,600);
QSplitter *splitter = new QSplitter(Qt::Horizontal);
splitter->addWidget(new QTextEdit());
splitter->addWidget(new GLWidget());
mainwindow.setCentralWidget(splitter);
mainwindow.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks