Details
-
Bug
-
Resolution: Out of scope
-
P3: Somewhat important
-
None
-
5.3.2, 5.4.0
-
None
-
Windows 7
Description
My app is composed of two processes a master and a slave. The slave is created by the master using QProcess. The master is attaching the slave window by using QWindow::fromWinId() and QWidget::createWindowContainer().
The bug is that the geometry of the slave is totally wrong: it is not expanding to the whole allocated space in the master window.
The really strange behavior is that if we open a dialog from the slave and then we resize the window then the issue is fixed! Below is a simple code snippet to reproduce the issue.
main.cpp
#include <QProcess> #include <QVBoxLayout> #include <QLabel> #include <QMessageBox> #include <QTextStream> #include <QToolButton> #include <QWindow> int main(int argc, char** argv) { QApplication qapp(argc, argv); if (qapp.arguments().contains("--slave")) { QWidget slaveWindow; QVBoxLayout layout(&slaveWindow); QToolButton button; button.setText("Click Me"); button.connect(&button, &QToolButton::clicked, [&slaveWindow]() { QMessageBox::information(&slaveWindow, "Close Me", "Resize the mainWindow once this dialog is closed.", QMessageBox::Ok); }); layout.addWidget(new QLabel("slaveWindow", &slaveWindow)); layout.addWidget(&button); slaveWindow.setStyleSheet("background: red;"); slaveWindow.show(); QTextStream ostream(stdout); ostream << slaveWindow.winId(); ostream.flush(); return qapp.exec(); } else { QWidget mainWindow; QVBoxLayout layout(&mainWindow); QProcess process; WId processWid; process.start(qapp.applicationFilePath(), {"--slave"}); process.waitForReadyRead(); processWid = process.readAll().toUInt(); QWindow* window = QWindow::fromWinId(processWid); QWidget* widget = QWidget::createWindowContainer(window); layout.addWidget(new QLabel("mainWindow", &mainWindow)); layout.addWidget(widget); mainWindow.setStyleSheet("background: green;"); mainWindow.resize(400, 400); mainWindow.show(); return qapp.exec(); } }
Attachments
Issue Links
- relates to
-
QTBUG-41186 Clarify functionality of QWindow::fromWinId() on the various platforms
- Reported