[Qt-interest] QGraphicsView promotion

Sajjad dosto.walla at gmail.com
Tue Aug 3 17:48:32 CEST 2010


On Mon, Aug 2, 2010 at 12:23 PM, Sajjad <dosto.walla at gmail.com> wrote:

> Hello forum,
>
> I am trying to do opengl rendering to the QGraphicsView subclass. The
> mainwindow consists several QGraphicsViiew widgets which i have promoted to
> specialized ones.
>
>
> I have set the viewport and enabled opengl rendering inside the constructor
> of mainwindow() as follows:
>
>
>
> *****************************
>
> LightPositionWindow::LightPositionWindow(QWidget *parent)
>     :QMainWindow(parent)
> {
>     setupUi(this);
>
>
>     graphicsViewWorldSpace->setViewport(new
> QGLWidget(QGLFormat(QGL::SampleBuffers)));
>
> graphicsViewWorldSpace->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
>     graphicsViewWorldSpace->setScene(new GraphicsWorldScene);
>
> }
>
>
> ****************************
>
>
> But the progeam exits with a warning that i have specified , saying that
> OpenGL rendering context not found .
>

I may need to elaborate more on this. The program exits with the following
warning(qWarning) in drawBackground( ) function .

The viewport has been set to with the QWidget, and in this case it is
QGLWidget and the scene has been defined as well. I need some

hint from someone in the forum to track if the viewport is really has been
set or not.

>
>
> ************************************''
>
> void GraphicsWorldScene::drawBackground(QPainter *painter, const QRectF
> &rect)
> {
>     Q_UNUSED(rect);
>
>
>    * if(painter->paintEngine()->type() != QPaintEngine::OpenGL) {
>         qWarning("Scene cannot be rendered without the OpenGL support");
>         return;
>     }*
>
>
> glClearColor(mBackgroundColor.redF(),mBackgroundColor.greenF(),mBackgroundColor.blueF(),1.0);
>     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
>
>     glMatrixMode(GL_PROJECTION);
>
>     glPushMatrix();
>     glLoadIdentity();
>     gluPerspective(70,width()/height(),0.01,1000);
>
>     glMatrixMode(GL_MODELVIEW);
>     glPushMatrix();
>     glLoadIdentity();
>
>     const float pos[] = { mLightItem->x() - width() / 2, height() / 2 -
> mLightItem->y(), 512, 0 };
>     glLightfv(GL_LIGHT0, GL_POSITION, pos);
>     //glColor4f(m_modelColor.redF(), m_modelColor.greenF(),
> m_modelColor.blueF(), 1.0f);
>
>     glPopMatrix();
>
>     glMatrixMode(GL_PROJECTION);
>
>     glPopMatrix();
>
> }
>
>
>
>
> ***************************************
>
> In  the above the bold statement gets executed and the program does not
> proceed any furthur.
>
>
> Any idea why it is not finding the OpenGL cotext?
>
>
> Regards
> Sajjad
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100803/6fff2f34/attachment.html 


More information about the Qt-interest-old mailing list