Results 1 to 5 of 5

Thread: opengl widget not able to embed in QGraphicsView

  1. #1
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default opengl widget not able to embed in QGraphicsView

    Hi friends,

    i tried to embed a QOpenGL widget to my QGraphicsView using QGraphicsProxyWidget .. i tried
    adding the widget like this ..

    Qt Code:
    1. QGraphicsProxyWidget *proxy = scene->addWidget(glWidget);
    To copy to clipboard, switch view to plain text mode 
    but it returns warning as
    QPainter::begin: A paint device can only be painted by one painter at a time.
    and it not showing the widget ...
    when i replace the opengl widget with normal widget (QTextEdit) it renders it properly ..

    my openGL paintGL() code is..

    Qt Code:
    1. glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    2. glMatrixMode(GL_PROJECTION);
    3. glLoadIdentity ();
    4. glOrtho(this->max_x,this->max_y,this->min_x,this->min_y,-1.0f,1.0f);
    5. glPushMatrix();
    6. glBindTexture(GL_TEXTURE_2D, texture);
    7. glBegin (GL_TRIANGLE_STRIP);
    8. ....
    9. ....
    10. glEnd ();
    11. glPopMatrix();
    To copy to clipboard, switch view to plain text mode 


    please help me in solving this issue ... where it requires painter.save() function ..? or some other ..? in QGLWidget where i have to use Qt GL functions ..?

    please help me ... thanks in advance ..
    "Behind every great fortune lies a crime" - Balzac

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: opengl widget not able to embed in QGraphicsView

    Well, in the QGraphicsScene::addWidget documentation its clearly stated:

    Note that widgets with the Qt::WA_PaintOnScreen widget attribute set and widgets that wrap an external application or controller are not supported. Examples are QGLWidget and QAxWidget.
    in QGLWidget where i have to use Qt GL functions ..?
    What do you mean ? You dont know where to put your OpenGL code ? Again, have you read the docs ? http://doc.qt.nokia.com/stable/qglwidget.html

  3. #3
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: opengl widget not able to embed in QGraphicsView

    in QGLWidget where i have to use Qt GL functions ..?
    sorry instead of using QPainter i had written Qt GL functions ...

    Note that widgets with the Qt::WA_PaintOnScreen widget attribute set and widgets that wrap an external application or controller are not supported. Examples are QGLWidget and QAxWidget.
    fine ... stampede ... can u tell me is there any other option to embed a OpenGL widget ..?
    i got this reference http://www.qtcentre.org/threads/1230...sScene-problem
    "Behind every great fortune lies a crime" - Balzac

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: opengl widget not able to embed in QGraphicsView

    can u tell me is there any other option to embed a OpenGL widget ..?
    Honestly, I dont know. Docs says that its not supported, but in the thread you've linked seems to be some kind of workaround for this. There is a code sample as well.
    Just try the suggestions posted there and see how it goes.

  5. #5
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: opengl widget not able to embed in QGraphicsView

    thanks for reply ... stampede ..

    in that thread they are just adding that widget as seperate viewport not as QGraphicsItem ... ok i see is there any other way ..
    and once again thanks for reply ..
    "Behind every great fortune lies a crime" - Balzac

Similar Threads

  1. Replies: 22
    Last Post: 14th October 2010, 17:44
  2. Embed QColorDialog as a widget
    By totem in forum Qt Programming
    Replies: 2
    Last Post: 23rd January 2010, 00:40
  3. How do you embed a widget in a graphics item?
    By technoViking in forum Qt Programming
    Replies: 4
    Last Post: 10th November 2009, 06:09
  4. Embed QGraphicsView in the QGraphicsScene
    By maverick_pol in forum Qt Programming
    Replies: 1
    Last Post: 10th October 2008, 08:40
  5. Replies: 1
    Last Post: 14th June 2006, 14:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.