Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt 5.11 - Embed external application into QWidget
Qt 6.12 LTS is out! See what's new in the release blog

Qt 5.11 - Embed external application into QWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Guy.Chriqui
    wrote on last edited by
    #1

    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 !

    jsulmJ 1 Reply Last reply
    0
    • G Guy.Chriqui

      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 !

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      0x3200005

      How do you know this is the correct id?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • G Offline
        G Offline
        Guy.Chriqui
        wrote on last edited by Guy.Chriqui
        #3

        @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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt
        • Unsolved