[Interest] How to use QOpenGLWidget from Qt Creator
Max Paperno
max-l at wdg.us
Mon May 3 08:10:46 CEST 2021
Hi Nicholas,
What you want to do is create your custom QOpenGLWidget first (it could
be the bare minimum to start with, even just a header file with the
class declaration). Then in Qt Creator/Designer you want to "promote"
the placeholder QOpenGLWidget to your custom version. If you search on
"promote widget in Qt Designer" (or similar) you'll find more clues.
Here's a couple links to get you started.
https://stackoverflow.com/questions/8138711/creating-custom-widget-to-be-promoted-in-qt-designer
https://doc.qt.io/archives/qt-4.8/designer-using-custom-widgets.html
(see "Promoting Widgets" part).
Note that most customization to your widget won't actually show up in
Designer (it will act as a "generic" QOpenGLWidget in Designer). Nor
would any custom properties you create, etc. For that you'd need closer
integration by writing a plugin (which you probably don't need to do). See:
https://stackoverflow.com/questions/58714879/my-custom-widget-is-not-shown-in-qt-creator-qt-designer-but-it-is-shown-when-i
https://stackoverflow.com/questions/23275909/adding-widgets-to-qt-designer
HTH,
-Max
On 5/3/2021 1:12 AM, Nicholas Yue wrote:
> Hi,
>
> I used designer to create a QOpenGLWidget on a MainWindow
>
> I can retrieve the widget via findChild<QOpenGLWidget*>()
>
> My understanding is that to leverage the widget, there are a couple of
> virtual methods that needs to be overridden e.g. paintGL(), resizeGL(),
> initializeGL()
>
> However, the widget I retrieve via findChild() will be the base class
> without the overridden methods.
>
> I must be missing something here.
>
> Where can I read up more on how this can be resolved ?
>
> The OpenGL examples I found did not use Qt Creator to create the UI
>
> https://doc.qt.io/qt-5/qtopengl-hellogl2-example.html
>
> Cheers
> --
> Nicholas Yue
> Graphics - Arnold, Alembic, RenderMan, OpenGL, HDF5
> Custom Dev - C++ porting, OSX, Linux, Windows
> http://au.linkedin.com/in/nicholasyue
> https://vimeo.com/channels/naiadtools
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
>
More information about the Interest
mailing list