最近使用QT5写了一个UI,控制逻辑采用C++编写,与QML混合编程。主要实现主机和PLC的交互,编写,实现过程都挺顺利的。之前用C++,Qwidget开发过一个类似于桌面的小程序,有没有办法整合进去,通过该程序启动与PLC的通信。于是翻翻Qwidget帮助文档吧,运气还挺好,找到一个
QWidget * QWidget::createWindowContainer(QWindow * window, QWidget * parent = 0, Qt::WindowFlags flags = 0)
Creates a QWidget that makes it possible to embed window into a QWidget-based application.
The window container is created as a child of parent and with window flags flags.
Once the window has been embedded into the container, the container will control the window's geometry and visibility. Explicit calls to QWindow::setGeometry(), QWindow::show() or QWindow::hide() on an embedded window is not recommended.
The container takes over ownership of window. The window can be removed from the window container with a call to QWindow::setPar