我正在尝试在 qstackedwidget 中添加一个 qquickwidget 以及其他一些 qwidget。但是,当我尝试将当前小部件设置为 qquickwidget 时,窗口上不会出现任何内容。还有什么需要做的吗?我还将qquickwidget的view属性设置为 true
QQuickWidget* mRoom = new QQuickWidget;
connect(mRoom, SIGNAL(statusChanged(QQuickWidget::Status)), this, SLOT(StatusChanged(QQuickWidget::Status)));
mRoom->setSource(QUrl::fromLocalFile("C:/Users/visjain/Desktop/main_vishwas.qml"));
mRoom->setResizeMode(QQuickWidget::SizeRootObjectToView);
QStackedWidget* mStack = new QStackedWidget(mparent);
mStack->addWidget(mRoom);
mStack->setCurrentWidget(mRoom);
mRoom->show();
qml 代码 -
import QtQuick 2.5
import QtQuick.Window 2.2
Window {
visible: true
height: 1000
width: 1800
Rectangle{
height: parent.height
width: parent.width
color: "red"
}
}