Layout problems with QtWidget::createWindowContainer
-
I try to embed an empty, black QWindow in a Qt Widget application using QtWidget:: createWindowContainer (Qt 5.10.1 on Ubuntu 18.04 X64). The resulting wrapper widget should become the child of another QWidget which serves as a placeholder in the GUI, "ui->wgtScene":
QVBoxLayout * layout = new QVBoxLayout ( ui->wgtScene );
ui->wgtScene->setWindowFlags( Qt::FramelessWindowHint );
QWidget * wrapperWidget = QWidget::createWindowContainer ( new QWindow(), ui->wgtScene, Qt::Widget );
wrapperWidget->setFixedSize( 1000, 800 );
wrapperWidget->setStyleSheet ( "background-color:yellow;" );
wrapperWidget->show();
wrapperWidget->setFocus();
layout->addWidget ( wrapperWidget );
ui->wgtScene->setLayout ( layout );
The area where the window should be visible looks broken. It looks like the standard Qt gray background but at the edges you can see a small black rim that seems to come from the embedded window slightly off layout. If I replace wrapperWidget by a regular QWidget(), I see a nice yellow field at the right position.What am I doing wrong?
-
Ok, since apparently the answer is not easy let me phrase the question differently:
Should a QWindow embedded in createWindowContainer generally appear as a black rectangle?
-
Ok, since apparently the answer is not easy let me phrase the question differently:
Should a QWindow embedded in createWindowContainer generally appear as a black rectangle?
@Desperado17 said in Layout problems with QtWidget::createWindowContainer:
Should a QWindow embedded in createWindowContainer generally appear as a black rectangle?
What is the purpose of the QWindow?
I don't know the direct answer to your questions, but I do know that there are issues with trying to embed external windows into Qt widgets: https://bugreports.qt.io/browse/QTBUG-40320
-
@Desperado17 said in Layout problems with QtWidget::createWindowContainer:
Should a QWindow embedded in createWindowContainer generally appear as a black rectangle?
What is the purpose of the QWindow?
I don't know the direct answer to your questions, but I do know that there are issues with trying to embed external windows into Qt widgets: https://bugreports.qt.io/browse/QTBUG-40320
@JKSH Actually the QWindow is a QVulkanWindow or a custom window class where I switched Vulkan on. I just replaced it for the time being while testing.
The hello vulkan examples from qt work by the way but I cannot explain why as they do even less to enforce the layout.
-
@JKSH Actually the QWindow is a QVulkanWindow or a custom window class where I switched Vulkan on. I just replaced it for the time being while testing.
The hello vulkan examples from qt work by the way but I cannot explain why as they do even less to enforce the layout.
@Desperado17 said in Layout problems with QtWidget::createWindowContainer:
The hello vulkan examples from qt work by the way but I cannot explain why as they do even less to enforce the layout.
I can't see anything obviously wrong with your code.
I suggest you copy the Hello Vulkan example code into your project, and then gradually integrating it into your existing widget and modifying it to fit what you want.