Results 1 to 4 of 4

Thread: How to disable NextButton in QWizard ?

  1. #1

    Smile How to disable NextButton in QWizard ?

    Hi!

    I am working in Qt 4.3 and have created four pages. In the second page, it has a start pushbutton which is used to calibrate cards. I want to make the start pushbutton enabled and the Qwizard NextButton disabled when initialized. To do this I tried to disable the button in the initializePage() or QWizard’s nextId() funtion, but both do not work.

    In Qwizard::nextId():
    Qt Code:
    1. button(Qwizard::NextButton)->setEnabled(false);
    To copy to clipboard, switch view to plain text mode 

    In QwizardPage::initializePage():
    Qt Code:
    1. QabstractButton *btn = parentHandle->button(Qwizard::NextButton);
    2. Btn->setEnabled(false);
    To copy to clipboard, switch view to plain text mode 
    After I called wizard->show(), I do the following:
    Qt Code:
    1. wizard->button(Qwizard::NextButton)->setEnabled(false);
    To copy to clipboard, switch view to plain text mode 
    This can disable the QWizard’s NextButton, but if I call it before wizard->show(), it does not work.
    If I connect the start pushbutton click signal to a slot, which is to disable the Qwizard’s NextButton, when I click the button it can disable the QWizard’s NextButton. However, I don’t want it to be disabled when I click the button, only when it is initialized.

    Any suggestion will be greatly appreciate!
    Last edited by jpn; 26th May 2008 at 11:19. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to disable NextButton in QWizard ?

    Take a look at the docs of QWizardPage::isComplete().

  3. #3

    Default Re: How to disable NextButton in QWizard ?

    Thanks a million, It solved my problem, i did the following:

    Qt Code:
    1. bool QWizardPage::isComplete()const
    2. {
    3. if (startPushButton->isEnabled()) {
    4. return false;
    5. } else {
    6. return true;
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

    I am puzzled why I can't disable the QWizard's NextButton in QWizardPage::initializePage(). I did the following:
    Qt Code:
    1. QAbstractButton *button = wizard()->button(QWizard::NextButton);
    2. button->setEnabled(false);
    To copy to clipboard, switch view to plain text mode 

    If you have any suggestions why this is the case, I'd be interested to hear the reason!
    Any help would be appreciated!
    Last edited by litroncn; 27th May 2008 at 02:34. Reason: reformatted to look better

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to disable NextButton in QWizard ?

    Maybe the button gets enabled right after you disable it?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.