QWizard 按钮在哪里控制? [英] Where to control the QWizard button?

查看:34
本文介绍了QWizard 按钮在哪里控制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Qt,并且我使用了一个包含多个页面的 QWizard 对象.当涉及到特定页面时,我想先隐藏下一步"按钮,并在用户执行某些操作(例如单击单选按钮...)后显示它

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...)

当此特定页面出现时,我想对向导进行一些自定义控制.问题是,我知道如何隐藏按钮,但我不知道应该使用哪个功能.我尝试了 QWizardPage 构造函数、initializePage 函数、show"函数,但所有这些函数都不起作用.

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.

如果我把它放在 initializePage 函数中,某些 QWizard 函数会在 initializePage 函数之后重置按钮,所有自定义设置都将消失.

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.

而且show函数好像不能覆盖.

And the show function seems cannot be overwritten.

我真的不知道哪个功能可用.有没有像 MFC 中的 OnSetActive 或 JAVA 中的 Load 之类的功能?当页面显示出来时会调用哪个?

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?

推荐答案

最好的解决方案可能是使用 QWizardPage::registerField.它允许您定义必填字段/单选按钮/等.并且向导中的下一步和/或完成按钮仅在填写/选中所有必填字段时启用.

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.

参见 http://doc.trolltech.com/4.6/dialogs-licensewizard.html 使用此功能的示例.

See http://doc.trolltech.com/4.6/dialogs-licensewizard.html for an example which makes use of this functionality.

QWizard::button 提供对向导中按钮的访问.您是否尝试过类似 myWizard->button(QWizard::NextButton)->setEnabled(false) 之类的东西?

这篇关于QWizard 按钮在哪里控制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆