Qt QQ向导立即打开和关闭
单击按钮后,我正在使用此功能打开向导:Qt QQ向导立即打开和关闭,qt,Qt,单击按钮后,我正在使用此功能打开向导: void Go::runWizardSlot() { QWizard wizard; wizard.addPage(::createIntroPage()); wizard.setWindowTitle("Trivial Wizard"); wizard.show(); } 当我点击一个按钮时,这会打开对话框,但会立即关闭。以下是介绍函数: QWizardPage *createIntroPage() {
void Go::runWizardSlot()
{
QWizard wizard;
wizard.addPage(::createIntroPage());
wizard.setWindowTitle("Trivial Wizard");
wizard.show();
}
当我点击一个按钮时,这会打开对话框,但会立即关闭。以下是介绍函数:
QWizardPage *createIntroPage()
{
QWizardPage *page = new QWizardPage;
page->setTitle("Introduction");
QLabel *label = new QLabel("This wizard will help you register your copy "
"of Super Product Two.");
label->setWordWrap(true);
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(label);
page->setLayout(layout);
return page;
}
是否有任何函数使其保持打开状态?您不能在堆栈上创建向导实例,然后调用show()。Show不会被阻止,一旦runWizardSlot()退出,向导实例将立即被销毁 您有两个选择:
- 调用exec()而不是show()。如果您想要向导模式并且对结果感兴趣,则可以正常工作
- 使用show()但在堆上创建向导。特别是对于非模态对话框,我更喜欢这个而不是exec()