Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt 5.11 - Embed external application into QWidget



  • Hey , i'm trying to make an qt MainWindow application that show in QWidget ( ui->appWidget ) an external window (other app that i run from a QProcess ).

    Now , when i do so , the new widget get the ui->appWidget size ,
    but it doesn't get into it , it still show the external app as an external window.

    What i need to do to make it be embedded into the ui->appWidget ?

    this is my code :

    void MainWindow::runScript(QString command){
    
        //Set Procees to Scripts directory
        process.setWorkingDirectory(directory.currentPath() + "/Scripts");
    
        //Open command process
        process.start("./" + command + ".sh" );
    
        //Check if Script succeed to open
        if(process.waitForStarted() == false){
            qDebug() << "Error starting " << command << " Script";
            qDebug() << "ERROR: " << process.errorString();
       }else{
            qDebug() << "Script succeed to open";
        }
    
    
        QThread::msleep(5000); // make sure process is up.
    
        QWindow * window =  QWindow::fromWinId(0x3200005); // 0x3200005 - Hardcoded window id .
        QWidget * widget = createWindowContainer(window);
        QVBoxLayout * vl = new QVBoxLayout(ui->appWidget);
        vl->addWidget(widget);
        ui->appWidget->setLayout(vl);
        widget->show();
    
    }
    

    If more details are needed please tell me .

    Thanks for the help !


  • Qt Champions 2019

    @Guy.Chriqui said in Qt 5.11 - Embed external application into QWidget:

    0x3200005

    How do you know this is the correct id?



  • @jsulm
    By checking with the command :

    $xwininfo -display :0
    

    (working on Linux - Ubuntu 16.04)
    i will be glad to know If there is any dynamic way to check it.


Log in to reply