PDA

View Full Version : Best Way to Draw Large Image



JediMaster
11th October 2015, 06:28
Hi

I'm making an application which draws multiple large image (maybe only parts of the image in a QMidSubWindow), so I'd like to know what's the best way, QGLWidget or QGraphicsScene ?

BTW I got a issue on MAC 10.9.5 with Qt 4.8.7, the QGLWidget rendering area always occupies the whole client area, and always on top of any the other widgets. From my screenshot you will see the red area which is the GL canvas even overlaps the handle to scale window compared with the left. Maybe I'm using the old version ? Thanks !



class LocalGLWidget : public QGLWidget
{
public:

LocalGLWidget(QWidget * Parent = NULL)
:
QGLWidget(QGLFormat(QGL::SampleBuffers | QGL::DirectRendering), Parent)
{
setAutoFillBackground(false);
}

void initializeGL()
{
glViewport(0, 0, width(), height());
glClearColor(0.0f, 1.0f, 0.0f, 0.0f);
}

void paintGL()
{
glClear(GL_COLOR_BUFFER_BIT);

const int W = 512;
const int H = 256;

glBegin(GL_QUADS);
glColor3f(1.0f, 0.0f, 0.0f);glVertex2i(0, 0);
glColor3f(0.0f, 1.0f, 0.0f);glVertex2i(W, 0);
glColor3f(0.0f, 0.0f, 1.0f);glVertex2i(W, H);
glColor3f(1.0f, 1.0f, 1.0f);glVertex2i(0, H);
glEnd();
}

void resizeGL(int W, int H)
{
glViewport(0, 0, W, H);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, W, 0, H);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

};

class LocalGLSubWindow : public QMdiSubWindow
{
public:
LocalGLSubWindow(QWidget * Parent = NULL)
:
QMdiSubWindow(Parent)
{
setAutoFillBackground(false);

mGL = new LocalGLWidget();


setWidget(mGL);
}

LocalGLWidget * mGL;
};


11418