简体   繁体   English

将当前的QWidget替换为QMainWindow中的另一个QWidget

[英]Replace current QWidget to another QWidget in QMainWindow

I have some QWidget class which ui files are separate from QMainWindow ui file. 我有一些QWidget类,其ui文件与QMainWindow ui文件是分开的。

how to add or replace current QWidet which is glued to QMainWindow into other QWidget from different class and ui files on the same QMainWindow ? 如何在同一个QMainWindow上将不同的类和ui文件添加或替换当前QWidet并将其粘贴到QMainWindow到其他QWidget中?

If I understand you correctly, you are currently displaying one widget and upon an action, you want to hide that widget and display another one in its place. 如果我正确理解您的信息,那么您当前正在显示一个小部件,并且在执行某个操作时,您想要隐藏该小部件并在其位置显示另一个小部件。

If this is correct, you might want to look at QStackedLayout . 如果这是正确的,则可能要查看QStackedLayout

Add your widget headers (note that you have to generate the headers from ui and inherit ) into promoted widgets in your QMainWindow.ui. 将您的窗口小部件标题(注意,您必须从ui生成标题并继承 )添加到QMainWindow.ui中的提升的窗口小部件中。

Then, You just have to insert a QWidget,QFrame, ... depending on the base class of your widget, and right click on it and select your custom widget from Promote to.. Submenu. 然后,您只需要插入QWidget,QFrame,...,具体取决于窗口小部件的基类,然后右键单击它,然后从“升级到”中选择您的自定义窗口小部件即可。

Heres a link to QT manual 这是QT手册的链接

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

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