Qt QWizard新建向导实例

使用QWizard做新建向导,最简单的实例


class MyWizard : public QWizard
{
public:

    MyWizard(QWidget* parent = nullptr);

    QWizardPage* createFirstPage();

    QWizardPage* createSecondPage();

    QWizardPage* createThirdPage();
};

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

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

    firstPage->setButtonText(QWizard::BackButton, "back");
    firstPage->setButtonText(QWizard::NextButton, "next");//为next设置一个中文的名字
    firstPage->setButtonText(QWizard::CancelButton, "cancel");
    firstPage->setButtonText(QWizard::FinishButton, "finish");
    return firstPage;
}
QWizardPage* MyWizard::createSecondPage()
{
    QWizardPage* secondPage = new QWizardPage;
    secondPage->setTitle(tr("second"));
    QLabel* picLabel = new QLabel;
    picLabel->setPixmap(QPixmap(":/QtCanpoolDemo/res/2.jpg"));
    QHBoxLayout* secondLayout = new QHBoxLayout;
    secondLayout->addWidget(picLabel);
    secondPage->setLayout(secondLayout);

    secondPage->setButtonText(QWizard::NextButton, "next");
    secondPage->setButtonText(QWizard::BackButton, "back");
    secondPage->setButtonText(QWizard::CancelButton, "cancel");
    secondPage->setButtonText(QWizard::FinishButton, "finish");
    return secondPage;
}
QWizardPage* MyWizard::createThirdPage()
{
    QWizardPage* thirdPage = new QWizardPage;
    thirdPage->setTitle(tr("third"));
    QLabel* picLabel = new QLabel;
    picLabel->setPixmap(QPixmap(":/QtCanpoolDemo/res/3.jpg"));
    QHBoxLayout* thirdLayout = new QHBoxLayout;
    thirdLayout->addWidget(picLabel);
    thirdPage->setLayout(thirdLayout);

    thirdPage->setButtonText(QWizard::NextButton, "next");
    thirdPage->setButtonText(QWizard::BackButton, "back");
    thirdPage->setButtonText(QWizard::CancelButton, "cancel");
    thirdPage->setButtonText(QWizard::FinishButton, "finish");
    return thirdPage;
}

int main(int argc, char* argv[])
{
    QApplication app(argc, argv);

    MyWizard wizard;
    wizard.show();

    return app.exec();
}

相关推荐

  1. Docker 新建网络实现容器间通信

    2024-07-10 00:34:01       44 阅读
  2. XXL-JOB学习笔记-基于代码实现新建、修改任务

    2024-07-10 00:34:01       53 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-10 00:34:01       99 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-10 00:34:01       107 阅读
  3. 在Django里面运行非项目文件

    2024-07-10 00:34:01       90 阅读
  4. Python语言-面向对象

    2024-07-10 00:34:01       98 阅读

热门阅读

  1. Jacoco的覆盖率原理

    2024-07-10 00:34:01       25 阅读
  2. 中英双语介绍美国的州:阿肯色州(Arkansas)

    2024-07-10 00:34:01       32 阅读
  3. Socket网络通信流程

    2024-07-10 00:34:01       31 阅读
  4. 《妃梦千年》第二十九章:朝中波澜

    2024-07-10 00:34:01       25 阅读
  5. FineReport报表开发步骤

    2024-07-10 00:34:01       34 阅读
  6. py每日spider案例之magnet篇

    2024-07-10 00:34:01       22 阅读
  7. Gridea + SFTP +Docker + Nginx 配置博客-CSDN

    2024-07-10 00:34:01       27 阅读
  8. 工具推荐:滴答清单

    2024-07-10 00:34:01       24 阅读
  9. 怎么样调整分类的阈值

    2024-07-10 00:34:01       30 阅读
  10. 数据分表和分库原理

    2024-07-10 00:34:01       27 阅读
  11. sklearn中的Pipeline:构建无缝机器学习工作流

    2024-07-10 00:34:01       27 阅读
  12. 生成式人工智能:助攻开发者还是取代开发者?

    2024-07-10 00:34:01       28 阅读
  13. VBA 批量转换xls文件

    2024-07-10 00:34:01       26 阅读
  14. 逻辑回归不是回归吗?那为什么叫回归?

    2024-07-10 00:34:01       25 阅读