Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt OpenGL project[SOLVED]
Forum Updated to NodeBB v4.3 + New Features

Qt OpenGL project[SOLVED]

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dmitrij
    wrote on last edited by
    #1

    Hello!

    I decided to try an OpenGL technique in Qt. But from the first base step I have a small problem. What kind of project I need to create? Is it a common Qt Widget Project or is it GLSL?

    Thank you for answers beforehand.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Seba84
      wrote on last edited by
      #2

      Yes, it is a common qt widget project. For doing this you have to create your own QGLWidget class, which heritates QGLWidget and declare the 3 virtual functions:

      1. void initializeGL();
      2. void paintGL();
      3. void resizeGL(int , int );

      I am working an Qt OpenGL project right now. Here you have a class example from my program:
      @class QOpenGL : public QGLWidget {
      Q_OBJECT

      // OPENGL FUNCTIONS
      void initializeGL();
      void paintGL();
      void resizeGL(int , int );
      // MOUSE CONTROL FUNCTIONS
      void mousePressEvent(QMouseEvent*);
      void mouseReleaseEvent(QMouseEvent*);
      void mouseMoveEvent(QMouseEvent*);

      public:
      // CONSTRUCTOR
      explicit QOpenGL(QWidget *parent = 0);
      ~QOpenGL() { doneCurrent(); }
      };@
      You can see in fact that the QGLWidget is a child class of QWidget. On my example I re-implemented the mouse functions (from QWidget) in order to have control on mouse input. You can see Qt Help for more info.

      Cheers!

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Seba84
        wrote on last edited by
        #3

        I forgot, in your project file .pro you should also add the following line:
        @QT += opengl@

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dmitrij
          wrote on last edited by
          #4

          Thank you for your answer!

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved