user10609288
user10609288

Reputation:

How to show QWindow inside QMdiArea

I have a OpenGLWindow class that inherits QWindow and QOpenGLFunctions_3_3_Core, it's opening collada dae files (works fine in simple project).

Also i have a pdfViewer class that inherits from QWidgets.

I want to display this windows in MdiArea class:

void MainViewer::CreateSubWindow(QString &pathToFile)
{
    if (pathToFile.endsWith(".pdf"))
    {
        PdfViewer *newViewer=new PdfViewer(&pathToFile);
        m_LoadedFiles->insert(pathToFile,newViewer);//this qhash save inform of current opened docs, i need it
        m_MainMdiArea->addSubWindow(static_cast<PdfViewer*>(m_LoadedFiles->value(pathToFile)))->show();
    }
    if (pathToFile.endsWith(".dae"))
    {
        DaeViewer *newViewer=new DaeViewer(pathToFile);
        m_LoadedFiles->insert(pathToFile, newViewer);
        m_MainMdiArea->addSubWindow(m_LoadedFiles->value(pathToFile))->show();
        static_cast<DaeViewer*>(m_LoadedFiles->value(pathToFile))->OpenGLWindow::show();
        newViewer->setAnimating(true);
    }
    mdiSubWindowsCount++;
}

Getting the same result:

enter image description here

I understood that show method of QWidget and QWindow is different.

I want to see my openGlWindow in myMdiArea but don't know how to call show method

Upvotes: 0

Views: 105

Answers (1)

user10609288
user10609288

Reputation:

Solution:

enter image description here

DaeViewer *newViewer=new DaeViewer(pathToFile);
m_MainMdiArea->addSubWindow(QWidget::createWindowContainer(newViewer))->show();

Upvotes: 0

Related Questions