如何完全禁用或隐藏 QWizard 中的后退按钮?
我想禁用或隐藏 QWizard 对话框中的后退按钮。我该怎么做呢?
I want to disable or hide Back button in QWizard dialog. How can I do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我想禁用或隐藏 QWizard 对话框中的后退按钮。我该怎么做呢?
I want to disable or hide Back button in QWizard dialog. How can I do it?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
我查看了 Qt 的源代码,发现可以通过创建自定义按钮布局并在列表中省略“后退”按钮来隐藏“后退”按钮:
我希望这将为某人节省一些时间。
PS
AFAIU 为了避免使用 QTimer,需要修改 QWizard 源代码。最简单的方法是添加一个虚函数
虚拟无效按钮Updated();
并从 QWizard 的末尾调用它:
无效 QWizardPrivate::_q_updateButtonStates()
然后在您的 QWizard 子类中重新实现此 ButtonUpdated() 并禁用那里的“后退”按钮。
I've looked at Qt's sources and found out that it's possible to hide Back button by creating custom button layout and ommiting Back button in the list:
I hope this will save some time to somebody.
P.S.
AFAIU to avoid using QTimer it is needed to modify QWizard source code. The easies way will be to add a virtual function
virtual void buttonsUpdated();
and call it from the end of QWizard's:
void QWizardPrivate::_q_updateButtonStates()
Then reimplement this buttonsUpdated() in your QWizard sublass and disable Back button there.
另一种(可能更面向框架)方法是将 QWizardPage 设置为提交页面,该页面位于您希望禁用后退按钮的页面之前。只需在 QWizardPage 上调用
this.setCommitPage(true)
,下一页就不会启用后退按钮。来自 QWizardPage 文档
如果您希望禁用所有后退按钮,您可以在每个页面上调用它。
An alternative (maybe more framework oriented) way would be to set the QWizardPage, which comes before the page you want the back button to be disabled in, to be a commit page. Just call
this.setCommitPage(true)
on a QWizardPage and the next page wont have its back button enabled.from QWizardPage documentation
If you want all the back buttons to be disabled, you could just call it on every page.
调用
对我有用
(在 PyQt4 中)。
这实际上在每个向导页面上再次隐藏了后退按钮,但它达到了预期的效果。
Calling
in
worked for me (in PyQt4).
This effectively hides the back button again on every wizard page, but it achieves the desired effect.