简体   繁体   English

PySide / Qt菜单栏在替换后消失

[英]PySide/Qt Menu bar disappearing when replaced

I'm trying to replace the current Menu bar of my application with a new one (for when the user switches language), but after applying the change the menubar is disappearing. 我正在尝试用新的菜单栏替换新的菜单栏(当用户切换语言时),但是应用更改后,菜单栏消失了。 The strange thing is that the changes show for a split second before disappearing. 奇怪的是,更改在消失之前会显示一瞬间。

Any ideas what is happening? 有什么想法吗? The QMenu is pretty standard (File, Edit, View, etc.), and I'm just calling setMenuBar() on my main window. QMenu非常标准(文件,编辑,视图等),我只是在主窗口上调用setMenuBar()。

def reset_menu(self):
    menu_bar = QtGui.QMenuBar()
    ##
    ## Code to add menus and actions to QMenuBar
    ##
    self.setMenuBar(menu_bar)

Internationalization in Qt-based apps does not require manual recreation of GUI objects. 基于Qt的应用程序的国际化不需要手动重新创建GUI对象。 The right way to do it is described here http://pyqt.sourceforge.net/Docs/PyQt4/i18n.html 此处介绍了正确的方法, 网址为http://pyqt.sourceforge.net/Docs/PyQt4/i18n.html

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

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