QWizard Next, Back



  • Hi, I've been seeking the web a lot lately, trying to find how to disable the Next and Back button.
    (Check out by yourself @Stack Overflow and many other forums):

    Why would I do that? Look at Adding a printer in Windows 7

    !http://img.techtalkz.com/DeviceAndPrinter_Win7_8.jpg(Adding printer dialog)!

    I'm doing the exact same thing for my current project, and I can't produce that GUI.

    button(QWizard::NextButton)->setEnabled(false); // doesn't work

    Reimplementing isComplete: How? I have no fields at all, just two commandlinks.

    So how disable-ing the next button?

    Thank You!



  • So, why don't you just make isComplete return false then?



  • BEcause I need the next enabled afterward. If you can do the same think as windows did (make an intro, a page like illustrated above, and two separated pages and let me know how !) thanks for the quick reply!



  • In "QWizard":http://doc.qt.nokia.com/latest/qwizard.html you add "QWizardPage":http://doc.qt.nokia.com/latest/qwizardpage.html, so you can inherit QWidgetPage and in this class implement "isComplete()":http://doc.qt.nokia.com/latest/qwizardpage.html#isComplete
    Have a look to "this page":http://doc.qt.nokia.com/qq/qq22-qwizard.html#validatebeforeitstoolate also.



  • OK, only you know what changes once a user has pressed one of those buttons, so only you know what should change.

    It seems to me, that you basically want to take another route through your wizard based on which buttons is pressed, right? If so, then I think that is fairly easy to achieve.

    Let your command button set a value that informs you of which one was pressed. Emit the completeChanged() signal, and let isComplete() return true if that value is non-valid. Then, you trigger the next action programatically, by adding a signal moveNext to your QWizardPage subclass, and connect that with the QWizard next() slot.



  • How to implement the completeChanged()?



  • No need to implement it, just do:
    @
    emit completeChanged();
    @

    to notify connected objects (like QWizard) that the status (may) have changed. You never implement a slot; Qt does that for you.



  • Here are my current 2 button connect:

    (PS: Another Specialist recommanded me to do so, and it works)
    @QWizardPage* wizard_newdb::PageSelect()
    {
    ...
    connect(linkImp, SIGNAL(clicked()), this, SLOT(gotoImport()));
    connect(linkNew, SIGNAL(clicked()), this, SLOT(gotoCreate()));
    ...
    }

    void wizard_newdb::gotoImport()
    {
    removePage(Page_AfterSelection1);
    ...
    addPage(PageRecover());
    ...
    next();
    }

    void wizard_newdb::gotoCreate()
    {
    removePage(Page_AfterSelection1);
    ...
    addPage(PageCreate());
    ...
    next();
    }@

    So, I do the following?
    @connect(linkNew, SIGNAL(clicked()), this, SLOT(emit completeChange()));@

    Thanks



  • [quote author="Andre" date="1320941333"]No need to implement it, just do:
    @
    emit completeChanged();
    @

    to notify connected objects (like QWizard) that the status (may) have changed. You never implement a slot; Qt does that for you.[/quote]

    Finally got it, after LOT of thinking:

    1. I did object only for the selectPage
    2. did a public variable called bool isDecided in my Parrent QWizard.
    3. When either buttons are pressed, parent->isDecided = true; emit completedChanged() like the following:
      @void SelectPage::gotoCreate()
      {
      parentW->isNew = true;
      emit completeChanged();
      parentW->gotoCreate();
      }@
      Here is my code (partial)

    @NewDB::NewDB(QWidget *parent)
    : QWizard(parent)
    {
    setPage(Page_Intro, new IntroPage(this));
    setPage(Page_Select, new SelectPage(this));
    setPage(Page_After1, BlankPage());
    }

    void NewDB::gotoCreate()
    {
    removePage(Page_After1);
    addPage(CreatePage());
    next();
    }

    SelectPage::SelectPage(NewDB *parent)
    : QWizardPage(parent)
    {
    parentW = parent; // Object NewDB
    ...
    parentW->isNew = false;
    // Button Actions
    connect(linkNew, SIGNAL(clicked()), this, SLOT(gotoCreate()));
    ...
    }

    void SelectPage::gotoCreate()
    {
    parentW->isNew = true;
    emit completeChanged();
    parentW->gotoCreate();
    }

    bool SelectPage::isComplete () const {
    if(parentW->isNew == true)
    {
    return true;
    }
    else
    {
    return false;
    }
    }@

    Thanks a lot for the hint!


Log in to reply
 

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