In my Qt 5.3 application, I want to integrate the GUI from a child process into my main process' window:
QWidget
.WId
as returned from QWidget::winId()
to the parent (using IPC).QWindow::fromWinId()
and QWidget::createWindowContainer()
to create a QWidget
displaying the child process' GUI. This widget is embedded into another widget's layout.Observations:
QWidget::createWindowContainer()
to use a separate top-level window instead, the child is embedded just fine.QMessageBox
, the issue fixes itself, and the child is embedded correctly after the next resize of the parent.Especially the last point puzzles me. I tried to find out if running the QMessageBox
changes some flags on the child widget and if I can simulate these changes manually to work around the issue, without luck.
Does anyone have an idea what is happening here? What could the modal dialog possibly do to the widget that fixes the problem?
First off all - thank you for this question. Before this time I am do not know about this feature in Qt. I spend some time to implement your solution and have the same problem: white border.
After few tests I try to do window reparenting on the fly and instead white borders there was native OS borders:
It looks like when call QWidget::createWindowContainer
Qt get size of entire window, display QWidget
(with smaller size than entire window) and fill background with white color.
I found solution for this problem: set Qt::FramelessWindowHint
window flag for child widget before you call createWindowContainer
in parent window.
this->setWindowFlags(Qt::FramelessWindowHint);
I could not reproduce the problem with crash after resize. I add child widget to layout and it works fine.
You can look at my example source at Git Hub.
If it does not solve your problem with crash, please, provide some source for this issue.
NOTE: in example on GitHub i run child project, read winId from debug output, modify parent source and than run parent project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With