[Interest] Embedding QWindow

Ian Monroe ian at monroe.nu
Mon Aug 4 20:26:49 CEST 2014

On Mon, Aug 4, 2014 at 11:21 AM, rap <rap at dlc.fi> wrote:
> Thanks Ian,  I have studied that example but it does not give an answer.
> What I'm trying accomplish is to have a  MainWindow (derived from
> QApplication / QWidget) for user input, (buttons etc.) and then a QWindow
> derived class as the OpenGL drawing surface and also to be the centralwidget
> in the MainWindow . However, I haven't been able to get this to work
> (probably because QWindow is not a QWidget based class and thus won't be
> accepted as central*widget*).  I have read that there will be a
> QOpenGLWidget in future versions that may be just what I'm after, but for
> now I'm trying to find out if there is a workaround until that happens.
> This is how I have been doing things so far, the myGLWidget is currently
> QGLWidget based, and now I want/need to replace it with a QWindow based
> class. The MainWindow constructor:
> MainWindow::MainWindow(QWidget *parent) :  QMainWindow(parent)
> {
>    ui.setupUi(this);
>    glw = new myGLWidget();
>    setCentralWidget(glw);
>    glw->setAttribute( Qt::WA_DeleteOnClose );
> ...
> }
> All my OpenGL stuff is in the glw instance, using signals from
> MainWindow/user controls but mouse input directly.

Why do you want to use QWindow if you are using QWidget-based windows?
 QGLWidget seems like the correct solution.

You can embed a  QWindow inside a QWidget using QWidget::createWindowContainer.


More information about the Interest mailing list