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. Reference an object in a UI form to a created class (QOpenGLWidget)
Forum Update on Monday, May 27th 2025

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 1 Posters 1.1k Views
  • 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.
  • N Offline
    N Offline
    nate5000
    wrote on 18 Feb 2015, 19:38 last edited by
    #1

    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

    1 Reply Last reply
    0
    • N Offline
      N Offline
      nate5000
      wrote on 18 Feb 2015, 20:22 last edited by
      #2

      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.

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nate5000
        wrote on 18 Feb 2015, 20:42 last edited by
        #3

        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.

        1 Reply Last reply
        0

        1/3

        18 Feb 2015, 19:38

        • Login

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