Results 1 to 10 of 10

Thread: How to connect OpengL 3-4 to Qt?

  1. #1
    Join Date
    Jul 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default How to connect OpengL 3-4 to Qt?

    Hi everyone! I'm trying to connect to the new OpenGL. But success is not achieved.

    All I managed to do is create a new project and will place on it OpenGLWidget. What to do next I don't know.

    In example on opengl entire interface is created from the code without the use Qt designer. This option is not suitable for me. I'm placed OpenGLWidget and some buttons then I want to draw triangles or other primitives. No success. How to initialize OpenGL? Where I can place draw functions?

    I would be grateful for any help.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to connect OpengL 3-4 to Qt?

    Quote Originally Posted by NewQTUser777 View Post
    This option is not suitable for me.
    What is suitable for you then?

    I'm placed OpenGLWidget and some buttons then I want to draw triangles or other primitives. No success. How to initialize OpenGL? Where I can place draw functions?
    Did you read the docs on QOpenGLWidget? What methods did you reimplement?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to connect OpengL 3-4 to Qt?

    Quote Originally Posted by wysota View Post
    What is suitable for you then?
    I started using Qt as an alternative to Window API.
    Create a project, added OpenGLWidget, placed buttons and menu. And then ... I do not know what to do. I have no idea how to work with the ui elements from code.

    Quote Originally Posted by wysota View Post
    Did you read the docs on QOpenGLWidget? What methods did you reimplement?
    Yes. I tried to implement the initializeGL(), paintGL(), resizeGL(), but unfortunately. There is an opinion that in fact these functions are called not for my placed openGLWidget.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to connect OpengL 3-4 to Qt?

    Did you implement them in a class you then use to instantiate the GL widget? Did you promote the widget you placed on the form to that class?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jul 2015
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to connect OpengL 3-4 to Qt?

    Quote Originally Posted by wysota View Post
    Did you implement them in a class you then use to instantiate the GL widget? Did you promote the widget you placed on the form to that class?
    I'm added new class OpenGLrender:

    Qt Code:
    1. #ifndef OPENGLRENDER_H
    2. #define OPENGLRENDER_H
    3.  
    4.  
    5. class OpenGLrender : public QOpenGLWidget
    6. {
    7. public:
    8. OpenGLrender();
    9. };
    10.  
    11. #endif // OPENGLRENDER_H
    To copy to clipboard, switch view to plain text mode 

    Before that, I placed OpengLWidget on the form. What's next?
    Last edited by NewQTUser777; 16th July 2015 at 17:35.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to connect OpengL 3-4 to Qt?

    Nothing is "next". If you implement a class and never use it then why are you surprised its methods are not called? You have to instantiate that class either by doing it explicitly or by promoting an existing widget on a form to that class.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to connect OpengL 3-4 to Qt?

    class OpenGLrender : public QOpenGLWidget
    {
    // ...
    }
    And beyond what wysota told you, if you derive a class from anything in the QObject hierarchy, you need to include the Q_OBJECT macro in the class definition.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to connect OpengL 3-4 to Qt?

    You don't have to do that however usually you want to do that.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Jan 2011
    Posts
    212
    Thanks
    24
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to connect OpengL 3-4 to Qt?

    Check the following blog. It may help.

    http://openglrevisited.blogspot.se/

  10. #10
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to connect OpengL 3-4 to Qt?

    You don't have to do that however usually you want to do that.
    True, if you don't need to use the metainformation system in the class. But for newbies, sometimes it's good to get a habit started so that later we don't have to reply to the posts asking "why don't my slots work?"

Similar Threads

  1. Replies: 1
    Last Post: 27th June 2014, 17:29
  2. Replies: 5
    Last Post: 27th January 2014, 23:22
  3. Replies: 2
    Last Post: 9th May 2011, 11:38
  4. Replies: 16
    Last Post: 16th February 2010, 14:17
  5. Replies: 4
    Last Post: 10th November 2006, 16:38

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.