Results 1 to 3 of 3

Thread: problem adding QGlwidget into a QGraphicsScene

  1. #1
    Join Date
    May 2012
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default problem adding QGlwidget into a QGraphicsScene

    I have a class which was inherited from QGLWidget

    codes here:


    class NeHeWidget : public QGLWidget
    {
    Q_OBJECT

    public:

    NeHeWidget( QWidget* parent = 0, const char* name = 0, bool fs = false );
    ~NeHeWidget();

    protected:

    void initializeGL();
    void paintGL();
    void resizeGL( int width, int height );

    void keyPressEvent( QKeyEvent *e );

    protected:

    bool fullscreen;
    GLfloat rTri;
    GLfloat rQuad;

    };


    so I tried to place this OpenGl part into a window , which I can see the picture created by OpenGL on the left side , and buttons on the right side
    like in this picture:
    2447052_130887907094Zw.png

    I thought this class was inherited from QGLWidget
    so I guess I can use this :

    NeHeWidget w( 0, 0, fs );
    QGraphicsScene scene;
    QGraphicsProxyWidget *proxy = scene.addWidget(w,Qt::WindowFlags);


    but it doesn't work.
    the compiler says the error is:
    expected primary-expression before ')' token

    So how do I fix it?
    if I didn't placed in the QGraphicsScene , it works well

    or is there any way to do what was shown in the attachment?

    thank you in advance!
    THANKS A LOT
    Last edited by gch0214; 15th May 2012 at 09:21.

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem adding QGlwidget into a QGraphicsScene

    Qt Code:
    1. scene.addWidget(w,Qt::WindowFlags);
    2. ^^ this doesnt make sense
    To copy to clipboard, switch view to plain text mode 

    pick any value (or union of values from here)
    http://qt-project.org/doc/qt-4.8/qt....indowType-enum


    you cant pass a type name as an argument...

    thats like doing this:

    Qt Code:
    1. void foo(int x)
    2. {
    3. }
    4.  
    5. int main()
    6. {
    7. foo(int);
    8. }
    To copy to clipboard, switch view to plain text mode 
    Which, hopefully looks a bit daft to you.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. The following user says thank you to amleto for this useful post:

    gch0214 (15th May 2012)

  4. #3
    Join Date
    May 2012
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem adding QGlwidget into a QGraphicsScene

    thanks for your reply, I finally achieved it

Similar Threads

  1. Adding QGLWidget to QGraphicsScene problem
    By sanjayshelke in forum Qt Programming
    Replies: 10
    Last Post: 26th April 2016, 15:03
  2. Problem adding QGLWidget to QGridLayout
    By Marga in forum Qt Programming
    Replies: 2
    Last Post: 21st September 2011, 14:52
  3. QgraphicsScene on QGLWidget background
    By ksrini in forum Qt Programming
    Replies: 2
    Last Post: 30th October 2009, 09:57
  4. QGLWidget inside QGraphicsScene/View
    By h123 in forum Qt Programming
    Replies: 3
    Last Post: 10th January 2009, 08:46
  5. Replies: 0
    Last Post: 7th April 2008, 14:27

Tags for this Thread

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.