Qt World Summit: Register Today!

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();
            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);

    If more details are needed please tell me .

    Thanks for the help !

  • Lifetime Qt Champion

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


    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