QWizard size problem and QWizardPage::setTitle



  • When creating QWizard and not setting page title, in some cases the min size isn't calculated correctly and wizard's content (if big enough) becomes squeezed or invisible.

    QWizardPrivate has the following code:
    @
    void QWizardPrivate::updateLayout()
    {
    ...

    QWizardLayoutInfo info = layoutInfoForCurrentPage();
    if (layoutInfo != info)
        recreateLayout(info);
    

    @

    Initial layout is build incorrectly and setTitle causes QWizardLayoutInfo to change (title flag becomes true), thus when calling setVisible (true), since layoutInfo was changed, recreateLayout will be called.

    But if not calling setTitle and calling one of the setOptions (in the example below: wizard->setOption (QWizard::NoBackButtonOnStartPage, true); ), then recreateLayout will be called as result of setOption (with incorrect sizes). And later when show will be called, since there was no change in QWizardLayoutInfo, recreateLayout won't be called and wizard will show its content incorrectly.

    1. Qt documentation contains this phrase regarding wizard page title: "All pages should have a title." Is it mandatory? Can it be overridden?
    2. Initial size calculation are incorrect. Is it a familiar problem? Can I somehow make sure that size calculation will be correct?

    Thanks in advance,
    Lev

    Code example:
    @
    QVBoxLayout* createVBoxLayout () {

    QLabel *label = new QLabel ("This is a very very long label AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n"            "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n"        "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n"
    

    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n"
    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n"
    "AAAAAA END");

    QRadioButton *radio1 = new QRadioButton ("Rad&io button 1");
    QRadioButton *radio2 = new QRadioButton ("Radi&o button 2");
    QRadioButton *radio3 = new QRadioButton ("Radio &button 3");
    radio1->setChecked (true);
    QCheckBox *checkBox = new QCheckBox ("Ind&ependent checkbox");
    checkBox->setChecked (true);
    
    QVBoxLayout *vbox = new QVBoxLayout;
    vbox->addWidget (label);
    vbox->addWidget (radio1);
    vbox->addWidget (radio2);
    vbox->addWidget (radio3);
    vbox->addWidget (checkBox);
    
    return vbox;
    

    }

    QWizardPage* createIntroPage () {
    QWizardPage *page = new QWizardPage;
    // page->setTitle ("Introduction");

    page->setLayout (createVBoxLayout ());
    
    return page;
    

    }

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

    QWizard* wizard = new QWizard ();
    wizard->addPage (createIntroPage ());
    wizard->setOption (QWizard::NoBackButtonOnStartPage, true);
    
    wizard->setWindowTitle ("Trivial Wizard");
    wizard->show ();
    
    return app.exec ();
    

    }
    @



  • Hi,
    First of all, your might have a memory leak on your hands. I do not believe that the QVBoxLayout is the parent of the radiobuttons, so cleaning that piece of memory is your buisness and Qt will not help you with that. The layout only controls the looks of the widgets IYAM.
    All pages need a title, so the next/previous know where to go in the QWizard. There is a very excellent doc about the QWizard.
    "Wizard example":http://qt-project.org/doc/qt-4.8/dialogs-classwizard.html



  • Thanks Greetz, Jeroen for your reply.

    First of all, you've touched only first part of my question and there were two, which might be related. And secondly when checking page title usages I didn't see that it's used in such manner. Moreover, each page has a page ID (an integer value) and to my understanding it's used for navigation.



  • Ok,
    1: Should have, so it's recommended! Id's are used for page navigation
    2: Never experienced that problem! When setting the Layouts properly, it all should be displayed perfectly.
    @
    WizardLoadMapFile::WizardLoadMapFile(QWidget * parent)
    : QWizard(parent)
    {
    setPage(Page_Intro, new IntroPage);
    setPage(Page_FileOpen , new OpenFilePage);
    m_LastPage = new ExecuteReadPage();
    setPage(Page_ReadFileData, m_LastPage);

    setPixmap(QWizard::WatermarkPixmap, QPixmap(":/Icons/Icons/Matrix2.jpg"));
    setPixmap(QWizard::LogoPixmap, QPixmap(":/Icons/Icons/RC30-icon-48x48.png"));
    //setPixmap(QWizard::BannerPixmap, QPixmap(":/Icons/Icons/NegativeSmile.png"));
    setPixmap(QWizard::BackgroundPixmap, QPixmap(":/Icons/Icons/RC30Controller.JPG"));
    
    setWindowTitle(tr("Load Map file wizard"));
    setModal(true);
    

    #ifndef Q_WS_MAC
    setWizardStyle(QWizard::ModernStyle);
    #endif
    //setButton(QWizard::NextButton);
    }

    IntroPage::IntroPage(QWidget *parent)
    : QWizardPage(parent)
    {
    setTitle(tr("Introduction"));
    setSubTitle(tr(" "));

    m_Label = new QLabel (tr("This wizard will guide you through the loading of the "
                             "RC30 memory map file to indicate memory usage!") );
    m_Label->setWordWrap(true);
    
    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(m_Label);
    setLayout(layout);
    

    }
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.