Reference an object in a UI form to a created class (QOpenGLWidget)



  • Hi everyone,
    I'm a noob to QT and the forums. Mostly a C guy so my issues may be my OOP misunderstandings.

    Here's what I'm trying to do: Implement opengl in a region on a UI form. I've designed the UI using the Qt UI form builder, and dropped my QOpenGLWidget onto a VBox container. And now I want to write the code to make that object do things in opengl. I've taken from the hellogl2 example, (which renders opengl on the screen), and saw that all the openGL stuff was implemented as a class and instantiated in the main gui startup code.

    So I created a duplicate of that example class (which implements a QOpenGLWidget) in my code, but cant tie it to the QOpenGLWidget that I dropped in my UI design. Does anyone know how to do this? I'm using Qt 5.4

    I've looked at making changes in the compiler generated source files (generated from the XML file that describes how the gui was built), but anything I do there will be lost once I recompile. Essentially I want to switch out in that generated code, the QOpenGLWidget it implements with my own class that uses the QOpenGLWidget but I dont know how to do this.

    Thanks for the help! Hope this is in the correct spot.
    -Nate



  • OK, so some updates:
    I was totally able to map to a Vbox I created with the UI designer, but as mentioned above, I mod'd the UI compiled code and switched out the QOpenGLWidget with references to my class, and it operated from the duplicate class instance from the hellogl2 example, so its definitely possible to render opengl on regions of a form created by the UI builder. but as said, the moment I try to rebuild /change the UI at all the UI compiler will overwrite my changes.
    Here's my next steps: see if I can get a reference to the VBox in the UI, and add directly in my main class instantiation code (after the ui->setup function), and embed my mapping there, then as long as I keep the names of objects the same/dont delete the parent, I should be able to map my gui class to my ui and leverage the UI functionality for building gui's.



  • This worked as well, Now I can get my openGL object running on a screen region without editing the created UI file directly, so my code to tie the opengl class object into the UI doesnt get bashed on UI change. But now I need to workout how my containers are placing things, so I know where/what ID's are associated with what portions of a container so I can always tie my opengl class to that portion of the container, as when I mod my UI it changes all the container specifics, which changes where my opengl class appears on the screen. But effectively this is a success.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.