Reputation: 53
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 !
Upvotes: 2
Views: 3452
Reputation: 4630
Probably you are setting the layout to the wrong widget.
Take a look at this piece of code, it moves an existing window (dolphin file manager - I retrieved the window id through the xwininfo command) inside a QMainWindow:
int main( int argc, char** argv )
{
int l_result = -1;
QApplication app(argc,argv);
QMainWindow* l_main_win = new QMainWindow();
l_main_win->setWindowTitle("DOLPHIN EMBEDDED IN QT APPLICATION!");
QWindow *l_container = QWindow::fromWinId(0x4400005);
QWidget *l_widget = QWidget::createWindowContainer(l_container);
l_main_win->setCentralWidget(l_widget);
l_main_win->show();
l_result = app.exec();
return l_result;
}
and it moves my dolphin window inside a Qt main window named "DOLPHIN EMBEDDED IN QT APPLICATION!":
Upvotes: 2