I'm interested in embedding an external application inside of my QT 5.5 Widget based application. I'm only concerned with it working on Linux. I'm using CentOS 7 with GNOME.
This is the code I have tried:
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
QWindow *window = QWindow::fromWinId(125829124);
QWidget *widget = QWidget::createWindowContainer(window);
widget->setParent(this);
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(widget);
this->setLayout(layout);
}
In this example I'm getting the WinId separately and just hard-coding the value for testing. The application to be embedded is running.
When I execute my Application it runs with no errors. And the application to be embedded changes screen position and resizes, however it does not embed inside my application. It is still a separate window. If I kill my application, the embedded application is killed as well.
So is there a way to actually embed the application inside of my application?
*************** UPDATE ****************
Something interesting I just uncovered. When I run my application (container application) the second application (the one I want embedded) remains an independent Window outside of my application. However if I resize my application window (click the lower right corner to resize the window) the second application (to be embedded) resizes as well, but remains an independent Window outside of my container application.
Even more interesting is that if I kill my application, both applications "disappear" from the desktop. However System Monitor shows the second application (the one I want embedded) is still running (however with no GUI). Now if I launch my application again the second application is in fact embedded in my container application, just the way I would like!
So I guess I have to figure out why killing my application and then relaunching it embeds the second application correctly.
See Question&Answers more detail:os