0
点赞
收藏
分享

微信扫一扫

Qt QWizard新建向导实例


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

Qt QWizard新建向导实例_qt

Qt QWizard新建向导实例_显示格式_02

Qt QWizard新建向导实例_qt_03

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

举报

相关推荐

0 条评论