Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

menuBar翻译 #4

Open
huweiuds opened this issue Oct 11, 2022 · 3 comments
Open

menuBar翻译 #4

huweiuds opened this issue Oct 11, 2022 · 3 comments

Comments

@huweiuds
Copy link

huweiuds commented Oct 11, 2022

No description provided.

@gnibuoz
Copy link
Owner

gnibuoz commented Nov 21, 2022

No description provided.

是指的预留多语言处理接口,支持后期实现语言切换吗?这个确实目前没有做相应的处理,比较忙,有空了处理下

@huweiuds
Copy link
Author

谢谢大佬的回复。先前的情况是menubar的地方不可支持后期翻译,而下面的qaction可翻译。应该是在初始化函数中把

@gnibuoz
Copy link
Owner

gnibuoz commented Nov 22, 2022

谢谢大佬的回复。先前的情况是menubar的地方不可支持后期翻译,而下面的qaction可翻译。应该是在初始化函数中把

QRibbon中的menubar实质上会被替换为一个QTabWidget控件,菜单项会被设置为Tab页的标题,二三级菜单会被替换为对应的QToolButton,之前的QAction则被关联到对应QToolButton的defaultAction中,此二者关系详见下图(Qt5.12.10 Assistant):
image
因此调用翻译旧QAction(即原菜单项)时,会自动更新对应QToolButton的文字,所以算是间接实现了菜单项的翻译功能,而QTabWidget标签名(即menubar)未做相应处理,所以即使翻译了原QMenuBar,对应的QTabWidget标签名文本也不会自动更新,因此,最简单的实现方式是,在构造中,将原QMenu的menuAction以下信号进行绑定,当menu文字等属性变化时,重新设置QTabWidget对应标签页的标题即可:
image

近几天有空了我会提交代码更新,你有空也可以试试,感谢反馈!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants