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. Where is QOpenGLWidget?
Forum Updated to NodeBB v4.3 + New Features

Where is QOpenGLWidget?

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 6 Posters 4.5k Views 3 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.
  • Tom assoT Offline
    Tom assoT Offline
    Tom asso
    wrote on last edited by
    #1

    I'm trying to write a C++ application that uses QOpenGLWidget, but qtcreator gives "'QOpenGLWidget' file not found" error on this line:

    #include <QOpenGLWidget>
    

    Documentation says QOpenGLWidget was introduced in Qt 5.4, and I believe I am running Qt 5.12; 'qmake --version' gives:

    QMake version 3.1
    Using Qt version 5.12.1 in /home/oreilly/Qt5.12.1/5.12.1/gcc_64/lib

    What am I doing wrong?

    Thanks
    Tom

    K JKSHJ 2 Replies Last reply
    0
    • Tom assoT Tom asso

      I'm trying to write a C++ application that uses QOpenGLWidget, but qtcreator gives "'QOpenGLWidget' file not found" error on this line:

      #include <QOpenGLWidget>
      

      Documentation says QOpenGLWidget was introduced in Qt 5.4, and I believe I am running Qt 5.12; 'qmake --version' gives:

      QMake version 3.1
      Using Qt version 5.12.1 in /home/oreilly/Qt5.12.1/5.12.1/gcc_64/lib

      What am I doing wrong?

      Thanks
      Tom

      K Offline
      K Offline
      kenchan
      wrote on last edited by
      #2

      @Tom-asso
      What does you .pro file look like?

      1 Reply Last reply
      1
      • Tom assoT Tom asso

        I'm trying to write a C++ application that uses QOpenGLWidget, but qtcreator gives "'QOpenGLWidget' file not found" error on this line:

        #include <QOpenGLWidget>
        

        Documentation says QOpenGLWidget was introduced in Qt 5.4, and I believe I am running Qt 5.12; 'qmake --version' gives:

        QMake version 3.1
        Using Qt version 5.12.1 in /home/oreilly/Qt5.12.1/5.12.1/gcc_64/lib

        What am I doing wrong?

        Thanks
        Tom

        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        Where is QOpenGLWidget?

        It is in the Qt Widgets module. So if #include <QWidget> works, then #include <QOpenGLWidget> should also work.

        Make sure your .pro file is set to use the Qt Widgets module (something like QT += widgets)

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        2
        • Tom assoT Offline
          Tom assoT Offline
          Tom asso
          wrote on last edited by
          #4

          My .pro file had this entry:
          QT += quick

          I added the following:
          QT += opengl

          And now qtcreator finds QOpenGLWidget

          Thanks
          Tom

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi,

            As @JKSH already wrote, you are missing QT += widgets in your .pro file.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • A Offline
              A Offline
              appas
              wrote on last edited by
              #6

              Just for anyone searching, in Qt6 you need to add

              QT += openglwidgets
              
              F 1 Reply Last reply
              5
              • A appas

                Just for anyone searching, in Qt6 you need to add

                QT += openglwidgets
                
                F Offline
                F Offline
                finchren
                wrote on last edited by
                #7

                @appas Thank you, you saved me)

                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