PDA

View Full Version : QWizard not showing



Ossi
1st September 2009, 14:37
Hi all.

I am having trouble getting my QWizard to work.

I have the following QAction:


newAction = new QAction(QIcon(":/images/png/16x16/note_add.png"), tr("&New"), this);
newAction->setShortcut(QKeySequence::New);
newAction->setStatusTip(tr("Create new profile"));
connect(newAction, SIGNAL(triggered()), this, SLOT(newSlot()));

and the newSlot, slot:


void MainWindow::newSlot()
{
NewWizard wizard;
wizard.show();

}

And my NewWizard class:


NewWizard::NewWizard(QWidget *parent) : QWizard(parent)
{
addPage(new IntroPage);
addPage(new InformationPage);

setPixmap(QWizard::BannerPixmap, QPixmap(":/images/png/tux.png"));
setPixmap(QWizard::BackgroundPixmap, QPixmap(":/images/png/tux.png"));

setWindowTitle(tr("New profile"));
}

IntroPage::IntroPage(QWidget *parent) : QWizardPage(parent)
{
setTitle(tr("Introduction"));
setPixmap(QWizard::WatermarkPixmap, QPixmap(":/images/png/tux.png"));

QLabel *label = new QLabel(tr("bla bla bla bla bla bla bla"));
label->setWordWrap(true);

QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(label);

setLayout(layout);
}

InformationPage::InformationPage(QWidget *parent) : QWizardPage(parent)
{
setTitle(tr("Information"));

QLabel *label = new QLabel(tr("bla bla bla bla bla bla bla"));
label->setWordWrap(true);

QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(label);

setLayout(layout);
}

But when I go to the menu and choose the new action, the wizard is not displayed. What am I doing wrong?

wysota
1st September 2009, 15:22
http://www.qtcentre.org/forum/faq.php?faq=qt_general_category#faq_qt_stack_creat ed_widgets

Ossi
1st September 2009, 15:43
http://www.qtcentre.org/forum/faq.php?faq=qt_general_category#faq_qt_stack_creat ed_widgets

Thanks alot

karaboutchov
10th May 2011, 17:54
I'm having the same problem. But the link in the previous answer seems to be broken....
Is it possible to launch a QWizard from a QMainWindow ?

falconium
10th May 2011, 22:00
Either call wizard.exec(); or instantiate NewWizard:

NewWizard *wizard = new NewWizard;
wizard->show();

ChrisW67
11th May 2011, 06:25
http://www.qtcentre.org/faq.php?faq=qt_general_category#faq_qt_stack_creat ed_widgets
Learn a bit about the scope of objects in C++ and it will probably become clearer.



Is it possible to launch a QWizard from a QMainWindow ?

Yes.