【Qt之QWizard】使用1

本文详细介绍了Qt中的QWizard类,包括其枚举(如WizardButton、WizardOption和WizardStyle)、常用方法(如添加页面、设置按钮、选项和样式)以及示例代码。展示了如何创建和定制向导对话框以引导用户逐步完成任务。

描述

QWizard类为向导提供了一个框架。

向导(在macOS上也称为助手)是一种特殊类型的输入对话框,由一系列页面组成。向导的目的是一步一步地指导用户完成流程。对于用户可能难以学习的复杂或不常见的任务,向导非常有用。

QWizard继承QDialog并表示向导。每个页面都是一个QWizardPage (QWidget的子类)。要创建您自己的向导,您可以直接使用这些类,或者您可以创建它们的子类以获得更多的控制。

方法

枚举:enum QWizard::WizardButton

此enum指定向导中的按钮。
关联函数:
可使用setButton(),setButtonText(),setButtonLayout()等函数进行设置。

常量 描述 解释
QWizard::BackButton 0 The Back button (Go Back on macOS) 后退按钮(在macOS上返回)
QWizard::NextButton 1 The Next button (Continue on macOS) Next按钮(macOS上的Continue)
QWizard::CommitButton 2 The Commit button 提交按钮
QWizard::FinishButton 3 The Finish button (Done on macOS) 完成按钮(在macOS上完成)
QWizard::CancelButton 4 The Cancel button (see also NoCancelButton) 取消按钮(参见NoCancelButton)
QWizard::HelpButton 5 The Help button (see also HaveHelpButton) 帮助按钮(参见HaveHelpButton)
QWizard::CustomButton1 6 The first user-defined button (see also HaveCustomButton1) 第一个用户定义的按钮(参见HaveCustomButton1)
QWizard::CustomButton2 7 The second user-defined button (see also HaveCustomButton2) 第二个用户定义的按钮(参见HaveCustomButton2)
QWizard::CustomButton3 8 The third user-defined button (see also HaveCustomButton3) 第三个用户定义按钮(参见HaveCustomButton3)

以下值只有在使用setButtonLayout()方法的时候有效:

常量 描述 解释
QWizard::Stretch 9 A horizontal stretch in the button layout 水平伸缩在按钮布局中
枚举:enum QWizard::WizardOption

此enum指定影响向导外观的各种选项。
关联函数:
setOptions(), setOption(), 和 testOption().

常量 描述 解释
QWizard::IndependentPages 0x00000001 The pages are independent of each other (i.e., they don’t derive values from each other). 各页面相互独立(即,它们不从彼此中派生值)。
QWizard::IgnoreSubTitles 0x00000002 Don’t show any subtitles, even if they are set. 即使已设置,也不显示任何副标题。
QWizard::ExtendedWatermarkPixmap 0x00000004 Extend any WatermarkPixmap all the way down to the window’s edge. 将任何水印位图一直扩展到窗口边缘。
QWizard::NoDefaultButton 0x00000008 Don’t make the Next or Finish button the dialog’s default button. 不要将“下一步”或“完成”按钮设置为对话框的默认按钮。
QWizard::NoBackButtonOnStartPage 0x00000010 Don’t show the Back button on the start page. 在起始页面上不显示“返回”按钮。
QWizard::NoBackButtonOnLastPage 0x00000020 Don’t show the Back button on the last page. 在最后一页上不显示“返回”按钮。
QWizard::DisabledBackButtonOnLastPage 0x00000040 Disable the Back button on the last page. 禁用最后一页上的“返回”按钮。
QWizard::HaveNextButtonOnLastPage 0x00000080 Show the (disabled) Next button on the last page. 在最后一页上显示(禁用)的“下一步”按钮。
QWizard::HaveFinishButtonOnEarlyPages 0x00000100 Show the (disabled) Finish button on non-final pages. 在非最终页面上显示(禁用)的“完成”按钮。
QWizard::NoCancelButton 0x00000200 Don’t show the Cancel button. 不显示“取消”按钮。
QWizard::CancelButtonOnLeft 0x00000400 Put the Cancel button on the left of Back (rather than on the right of Finish or Next). 将“取消”按钮放在“返回”按钮的左侧(而不是“完成”或“下一步”按钮的右侧)。
QWizard::HaveHelpButton 0x00000800 Show the Help button. 显示“帮助”按钮。
QWizard::HelpButtonOnRight 0x00001000 Put the Help button on the far right of the button layout (rather than on the far left). 将“帮助”按钮放在按钮布局的最右边(而不是最左边)。
QWizard::HaveCustomButton1 0x00002000 Show the first user-defined button (CustomButton1). 显示第一个用户定义的按钮(CustomButton1)。
QWizard::HaveCustomButton2 0x00004000 Show the second user-defined button (CustomButton2). 显示第二个用户定义的按钮(CustomButton2)。
QWizard::HaveCustomButton3 0x00008000 Show the third user-defined button (CustomButton3). 显示第三个用户定义的按钮(CustomButton3)。
QWizard::NoCancelButtonOnLastPage 0x00010000 Don’t show the Cancel button on the last page. 在最后一页上不显示“取消”按钮。

WizardOptions类型是qflag的类型定义。它存储了WizardOption值OR组合。

枚举:enum QWizard::WizardStyle

enum指定QWizard支持的不同外观。
关联函数:
可通过setWizardStyle()进行外观设置,如果不设置,使用setPixmap()方法设置位图无效。

常量 描述 解释
QWizard::ClassicStyle 0 Classic Windows look 经典的 Windows 外观
QWizard::ModernStyle 1 Modern Windows look 现代的 Windows 外观
QWizard::MacStyle 2 macOS look macOS 外观
QWizard::AeroStyle 3 Windows Aero look Windows Aero 外观
QWizard::NStyles 4 默认

在这里插入图片描述

枚举:enum QWizard::WizardPixmap

此enum指定可以与页面关联的像素图。
关联函数:
通过 setPixmap(), QWizardPage::setPixmap()等方法设置像素图。

常量 描述 解释
QWizard::WatermarkPixmap 0 The tall pixmap on the left side of a ClassicStyle or ModernStyle page ClassicStyle或ModernStyle页面左侧的高度较高的像素图
QWizard::LogoPixmap 1 The small pixmap on the right side of a ClassicStyle or ModernStyle page header ClassicStyle或ModernStyle页面标题栏右侧的小像素
QWizard::BannerPixmap 2 The pixmap that occupies the background of a ModernStyle page header 占用ModernStyle页面标题栏背景的像素图
QWizard::BackgroundPixmap 3 The pixmap that occupies the background of a MacStyle wizard 占用MacStyle向导背景的像素图
QWizard::NPixmaps 4 默认
常用成员方法
  • int addPage(QWizardPage *page):将给定的页面添加到向导中,返回新页面的ID。
  • QAbstractButton *button(WizardButton which) const:返回指定按钮类型的按钮(如下一步、上一步、完成等)。
  • QString buttonText(WizardButton which) const:返回指定按钮类型的文本。
  • int currentId() const:返回当前页面的ID。
  • QWizardPage *currentPage() const:返回当前页面。
  • QVariant field(const QString &name) const:返回具有给定名称的字段的值。
  • bool hasVisitedPage(int id) const:检查页面ID是否已经被访问过。
  • virtual int nextId() const:返回下一个要显示的页面的ID。
  • WizardOptions options() const:返回当前设置的选项。
  • QWizardPage *page(int id
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

FreeLikeTheWind.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值