Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QWizard size problem and QWizardPage::setTitle

QWizard size problem and QWizardPage::setTitle

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 3.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    levt39
    wrote on last edited by
    #1

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

    }
    @

    Z 1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      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

      Greetz, Jeroen

      1 Reply Last reply
      0
      • L Offline
        L Offline
        levt39
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • JeroentjehomeJ Offline
          JeroentjehomeJ Offline
          Jeroentjehome
          wrote on last edited by
          #4

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

          }
          @

          Greetz, Jeroen

          1 Reply Last reply
          0
          • L levt39

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

            }
            @

            Z Offline
            Z Offline
            zoujiu
            wrote on last edited by
            #5
            This post is deleted!
            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved