Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Controlling GL widget within QT
Forum Updated to NodeBB v4.3 + New Features

Controlling GL widget within QT

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
9 Posts 2 Posters 1.1k Views 2 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.
  • B Offline
    B Offline
    BKBK
    wrote on last edited by BKBK
    #1

    I am working at home on Windows and at work on Linux. This is at work. I am a novice at QT and OpenGL, don’t understand all I am trying now, and cannot copy paste from my work computer to this forum so please try to accommodate typos.

    I have created a QT dialog and incorporated a GL widget in it, but cannot set the color or properly control the size. So far I can display a QT widget with: a label and a Quit button in a Horizontal layout box. That layout box is then placed in a vertical layout box along with the widget described just below. The GL widget has random bits displayed, and is a fixed size. My immediate milestones are: clear to black and be resizable.
    Here is the GL widget with some of the later attempts commented out.

    C_gl_widget::C_gl_widget( QWidget * parent, const char *name )
       : QGLWidget( parent, name )
    {
    SetFormat( QGLFormat( DoubleBuffer | DepthBuffer ) ); 
    // qglClearColor( 0.0, 0.0, 0.0, 0.0 );  // no matching function call
    // glclearColor( black );   // not declared in this scope
    // glclearColor( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );  // won’t compile
    // glClear( 1 );
    // setSizePolicy( QSizePolicy::MinimumExpanding );
    // The line above will not make, The error message lists three of the QT include files and 
    // concludes with:  QSizePolicy::QSizePolicy(int) is private.
    SetMinimumjSize( 300, 400 ); // works, but cannot change the size at run time.
    }
    

    Question for the GL widget: What code will set the color to black? What code will cause it to be resizable?

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

      Hi,

      Since it's a new project, you should use QOpenGLWidget. There's an example in the details of the class that will get you started.

      As for the resizing, if you mean the widget itself, it will happen automatically if you put it in a properly applied layout.

      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
      • B Offline
        B Offline
        BKBK
        wrote on last edited by
        #3

        Hello SGaist,
        Thanks for the reply. Here at work, on a government computer and through their firewalls, I the link gives me a network error and a message about how Internet Usage is Logged. I will have to try that at home. I get those so much I just ignore them, except for the part about not being able to see the information needed. I will do some searching for that phrase and other sites that may help.
        Thanks again for your time.

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

          Unless you have some reduced Qt installation, you should have the full documentation at your disposal in Qt Creator.

          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
          • B Offline
            B Offline
            BKBK
            wrote on last edited by
            #5

            Why yes, we do have the QT3 and QT4 assistant installed. Thanks for the reminder.

            1 Reply Last reply
            0
            • B Offline
              B Offline
              BKBK
              wrote on last edited by
              #6

              I opened the QT3 and QT4 assistant, one on each of two monitors, clicked tab Search, entered that value, not found on either one. Did that in camel case then in lower case on both.

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

                QOpenGLWidget is Qt 5 so you have to stay with QGLWidget, but in any case, the documentation still provides an example on how to get started.

                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
                • B Offline
                  B Offline
                  BKBK
                  wrote on last edited by
                  #8

                  QGLWidget is mentioned in the QT3 book. I used it IAW with that book and compared with the QT4 book. We don't have QT5 and should not need it for now. I can create an OpenGL window within a QT dialog. My next milestone is just to clear the screen, but I cannot do that. I need some assistance and hints as to where to look.

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

                    Just take into account that Qt 4 has reached end of life since a few years already.

                    Again, the class documentation already shows the basics and links to several examples that should get you going.

                    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
                    1

                    • Login

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