2017年12月12日 星期二

Qt--QWizard向导界面

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;
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
截图
这里写图片描述
这里写图片描述
这里写图片描述

沒有留言:

張貼留言