Qt学习之QWizard向导界面

QWizard类提供了一个向导对话框的框架。
向导就是包含一组顺序的对话框页面的特定类型的输入对话框。向导的目的是让用户一步一步地完成一个过程。向导对于复杂或者偶尔发生的并且人们发现它很难学会或者执行的任务很有用处。
自己根据文档完成了一个小的例子,以备不时之需。

#include "mywizard.h"

MyWizard::MyWizard(QWidget *parent) :
    QWizard(parent)
{
    /*setOption( QWizard::NoBackButtonOnStartPage );
    setOption( QWizard::NoBackButtonOnLastPage );
    setOption( QWizard::NoCancelButton );*/

    this->setOption( QWizard::NoBackButtonOnStartPage );//设置第一页没有上一步的按钮
    this->setWizardStyle( QWizard::ModernStyle );//设置上一步下一步等按钮的显示格式
    this->addPage(createFirstPage());//添加自己写好的QWizardPage页面
    this->addPage(createSecondPage());
    this->addPage(createThirdPage());
}
QWizardPage *MyWizard::createFirstPage()
{
    QWizardPage *firstPage = new QWizardPage;
    firstPage->setTitle(tr("第一步"));//设置第一个QWizardPage
    QLabel *picLabel = new QLabel;
    picLabel->setPixmap(QPixmap(":/image/first.jpg"));
    QHBoxLayout *firstLayout = new QHBoxLayout;
    firstLayout->addWidget(picLabel);
    firstPage->setLayout(firstLayout);



    firstPage->setButtonText(QWizard::BackButton,"上一步");
    firstPage->setButtonText(QWizard::NextButton,"下一步");//为next设置一个中文的名字
    firstPage->setButtonText(QWizard::CancelButton,"取消");
    firstPage->setButtonText(QWizard::FinishButton,"完成");
    return firstPage;
}
QWizardPage *MyWizard::createSecondPage()
{
    QWizardPage *secondPage = new QWizardPage;
    secondPage->setTitle(tr("第二步"));
    QLabel *picLabel = new QLabel;
    picLabel->setPixmap(QPixmap(":/image/second.jpg"));
    QHBoxLayout *secondLayout = new QHBoxLayout;
    secondLayout->addWidget(picLabel);
    secondPage->setLayout(secondLayout);

    secondPage->setButtonText(QWizard::NextButton,"下一步");
    secondPage->setButtonText(QWizard::BackButton,"上一步");
    secondPage->setButtonText(QWizard::CancelButton,"取消");
    secondPage->setButtonText(QWizard::FinishButton,"完成");
    return secondPage;
}
QWizardPage *MyWizard::createThirdPage()
{
    QWizardPage *thirdPage = new QWizardPage;
    thirdPage->setTitle(tr("第三步"));
    QLabel *picLabel = new QLabel;
    picLabel->setPixmap(QPixmap(":/image/third.jpg"));
    QHBoxLayout *thirdLayout = new QHBoxLayout;
    thirdLayout->addWidget(picLabel);
    thirdPage->setLayout(thirdLayout);

    thirdPage->setButtonText(QWizard::NextButton,"下一步");
    thirdPage->setButtonText(QWizard::BackButton,"上一步");
    thirdPage->setButtonText(QWizard::CancelButton,"取消");
    thirdPage->setButtonText(QWizard::FinishButton,"完成");
    return thirdPage;
}

截图

这里写图片描述

这里写图片描述

这里写图片描述

源码下载地址

  • 7
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值