简体   繁体   English

如何在QT中为两个项目使用单个UI?

[英]How to use a single UI for two projects in QT?

I need a small help. 我需要一点帮助。 I have two projects in QT,one a publisher having mainwindow.cpp,main.cpp,mainwindow.ui,qnode and other a subscriber with the same number of files. 我在QT中有两个项目,一个是具有mainwindow.cpp,main.cpp,mainwindow.ui,qnode的发布者,另一个是具有相同文件数的订阅者。 i want to combine the two .ui files together or lets just say create a new .ui with two tabs each one accessing the publisher.ui and subscriber.ui. 我想将两个.ui文件组合在一起,或者只说创建一个带有两个选项卡的新.ui文件,每个选项卡都可以访问Publisher.ui和Subscriber.ui。 How can i do it? 我该怎么做?

You can use a QStackedWidget . 您可以使用QStackedWidget

http://doc.qt.io/qt-5/qstackedwidget.html http://doc.qt.io/qt-5/qstackedwidget.html

Simply add some QPushButton instances that can be checkable, and use those as your "tabs". 只需添加一些可检查的QPushButton实例,然后将其用作“选项卡”即可。 You can use the QStackedWidget index property quite easily with both QWidget UIs and QML UIs 您可以在QWidget UI和QML UI上轻松使用QStackedWidget索引属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM