[英]Adding QML file in MDI Subwindow
I'm trying to add some qml source file in MDI Subwindow that when I clicked the button we will show subwindow in MDI Area and the display will be the QML source file. 我试图在MDI子窗口中添加一些qml源文件,当我单击该按钮时,我们将在MDI区域中显示子窗口,并且显示的将是QML源文件。 Can I possibly add some qml in my MDI Subwindow?
我可以在我的MDI子窗口中添加一些qml吗? .
。 I highly appreciate any kind of answer, suggestion and idea regarding this matter, Thank you.
我非常感谢您对此事的任何回答,建议和想法,谢谢。
This is my sample code in adding subwindow in MDI Area, Where can I insert the code for adding qml source file? 这是我在MDI区域中添加子窗口的示例代码,在哪里可以插入用于添加qml源文件的代码?
void MainWindow::on_action_Weather_triggered()
{
subwindow3 = new QMdiSubWindow(mdiArea);
widget3 = new QWidget(subwindow3);
widget3->show();
subwindow3->setWidget(widget3);
subwindow3->resize(500,300);
subwindow3->setWindowTitle("Weather");
subwindow3->setAttribute(Qt::WA_DeleteOnClose,false);
mdiArea->addSubWindow(subwindow3);
subwindow3->hide();
mdiArea->setActiveSubWindow(subwindow3);
subwindow3->show();
}
You have to use QQuickWidget
: 您必须使用
QQuickWidget
:
*.pro * .pro
QT += quickwidgets
*.cpp * .cpp
QMdiSubWindow *subwindow = new QMdiSubWindow(mdiArea);
QQuickWidget* widget = new QQuickWidget(subwindow);
widget->setResizeMode(QQuickWidget::SizeRootObjectToView);
widget->setSource(QUrl("qrc:/main.qml"));
widget->show();
subwindow->setWidget(widget);
subwindow->resize(500,300);
subwindow->setWindowTitle("Weather");
subwindow->setAttribute(Qt::WA_DeleteOnClose,false);
mdiArea->addSubWindow(subwindow);
mdiArea->setActiveSubWindow(subwindow);
subwindow->show();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.