在哪里控制 QWizard 按钮?
我正在使用 Qt,并且使用包含多个页面的 QWizard 对象。 当涉及到特定页面时,我想先隐藏“下一步”按钮,并在用户执行某些操作(例如单击单选按钮...)后显示它,
我想对向导进行一些自定义控制显示特定页面。 问题是,我知道如何隐藏按钮,但我不知道应该使用哪个功能。 我尝试了 QWizardPage 构造函数、initializePage 函数、“show”函数,但所有这些函数都不起作用。
如果我将按钮控件放在向导页面构造函数中,则程序将崩溃,因为向导对象还不存在。
如果我把它放在initializePage函数中,一些QWizard函数将在initializePage函数之后重置按钮,并且所有自定义设置都会消失。
并且 show 函数似乎无法被覆盖。
我真的不知道哪个功能可用。 MFC中是否有OnSetActive或JAVA中的Load之类的函数? 当页面要显示时会调用哪个?
I'm using Qt, and I use a QWizard object which contains several pages.
when it comes to a specific page, I want to hide the "Next" button first, and shows it after the user do something (such as clicking on a radiobutton...)
I want to do some customize control of the wizard when this specific page shows up.
the question is, I know how to hide the button, but I don't know which function I should use.
I tried the QWizardPage constructor, the initializePage function, the "show" function, but all of these function didn't work.
If I put the button control in the wizard page constructor, the program will crash since the wizard object is not there yet.
If I put it in initializePage function, some QWizard function will reset the buttons after the initializePage function, and all the customized setting will gone.
And the show function seems cannot be overwritten.
I really cannot figure out which function is usable.
Is there any function like OnSetActive in MFC or Load in JAVA??
Which will be called when a page is going to shows out?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最好的解决方案可能是使用
QWizardPage::registerField< 提供的解决方案/代码>
。它允许您定义必填字段/单选按钮/等。仅当填写/选中所有必填字段后,向导中的“下一步”和/或“完成”按钮才会启用。
请参阅http://doc.trolltech.com/4.6/dialogs-licensewizard.html 查看使用此功能的示例。
编辑:
QWizard::button
提供访问向导中的按钮。您是否尝试过类似myWizard->button(QWizard::NextButton)->setEnabled(false)
?The best solution is probably the one provided by using
QWizardPage::registerField
. It allows you to define mandatory fields/radio buttons/etc. and the Next and/or Finish buttons in your wizard are enabled only when all mandatory fields are filled/checked.See http://doc.trolltech.com/4.6/dialogs-licensewizard.html for an example which makes use of this functionality.
EDIT:
QWizard::button
provides access to the buttons in the wizard. Have you tried something likemyWizard->button(QWizard::NextButton)->setEnabled(false)
?要禁用下一个按钮,您可以子类化
QWizardPage
并重新实现isComplete()
。当它返回 true 时,QWizard
将启用该按钮。当您更改isComplete()
的状态时,子类必须发出“completeChanged()”信号。QWizardPage
的文档解释了如何执行此操作。也许您也可以使用
parent->button(QWizard::NextButton)->setVisible(false)
来隐藏按钮。
To disable the next button you can subclass
QWizardPage
and reimplementisComplete()
. When it returns true thenQWizard
will enable the button. The subclass has to emit the 'completeChanged()' signal when you change the state ofisComplete()
. The documentation forQWizardPage
explains how to do it.Possibly you could also use
parent->button(QWizard::NextButton)->setVisible(false)
to hide the button.