November 10, 2011

xboxnissan xboxnissan
Lab Rat
5 posts

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

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!

8 replies

November 10, 2011

Andre Andre
Robot Herder
6394 posts

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

November 10, 2011

xboxnissan xboxnissan
Lab Rat
5 posts

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!

November 10, 2011

rokemoon rokemoon
Lab Rat
197 posts

In QWizard [doc.qt.nokia.com] you add QWizardPage [doc.qt.nokia.com], so you can inherit QWidgetPage and in this class implement isComplete() [doc.qt.nokia.com]
Have a look to this page [doc.qt.nokia.com] also.

November 10, 2011

Andre Andre
Robot Herder
6394 posts

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.

November 10, 2011

xboxnissan xboxnissan
Lab Rat
5 posts

How to implement the completeChanged()?

November 10, 2011

Andre Andre
Robot Herder
6394 posts

No need to implement it, just do:

  1. emit completeChanged();

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

November 10, 2011

xboxnissan xboxnissan
Lab Rat
5 posts

Here are my current 2 button connect:

(PS: Another Specialist recommanded me to do so, and it works)

  1. QWizardPage* wizard_newdb::PageSelect()
  2. {
  3.     ...
  4.     connect(linkImp, SIGNAL(clicked()), this, SLOT(gotoImport()));
  5.     connect(linkNew, SIGNAL(clicked()), this, SLOT(gotoCreate()));
  6.     ...
  7. }
  8.  
  9. void wizard_newdb::gotoImport()
  10. {
  11.     removePage(Page_AfterSelection1);
  12.     ...
  13.     addPage(PageRecover());
  14.     ...
  15.     next();
  16. }
  17.  
  18. void wizard_newdb::gotoCreate()
  19. {
  20.     removePage(Page_AfterSelection1);
  21.     ...
  22.     addPage(PageCreate());
  23.     ...
  24.     next();
  25. }

So, I do the following?

  1. connect(linkNew, SIGNAL(clicked()), this, SLOT(emit completeChange()));

Thanks

November 10, 2011

xboxnissan xboxnissan
Lab Rat
5 posts

Andre wrote:
No need to implement it, just do:
  1. emit completeChanged();

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

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:

  1. void SelectPage::gotoCreate()
  2. {
  3.     parentW->isNew = true;
  4.     emit completeChanged();
  5.     parentW->gotoCreate();
  6. }

Here is my code (partial)

  1. NewDB::NewDB(QWidget *parent)
  2.     : QWizard(parent)
  3. {
  4.     setPage(Page_Intro, new IntroPage(this));
  5.     setPage(Page_Select, new SelectPage(this));
  6.     setPage(Page_After1, BlankPage());
  7. }
  8.  
  9. void NewDB::gotoCreate()
  10. {
  11.     removePage(Page_After1);
  12.     addPage(CreatePage());
  13.     next();
  14. }
  15.  
  16. SelectPage::SelectPage(NewDB *parent)
  17.     : QWizardPage(parent)
  18. {
  19.     parentW = parent; // Object NewDB
  20.     ...
  21.     parentW->isNew = false;
  22.     // Button Actions
  23.     connect(linkNew, SIGNAL(clicked()), this, SLOT(gotoCreate()));
  24.     ...
  25. }
  26.  
  27. void SelectPage::gotoCreate()
  28. {
  29.     parentW->isNew = true;
  30.     emit completeChanged();
  31.     parentW->gotoCreate();
  32. }
  33.  
  34. bool SelectPage::isComplete () const {
  35.   if(parentW->isNew == true)
  36.   {
  37.       return true;
  38.   }
  39.   else
  40.   {
  41.       return false;
  42.   }
  43. }

Thanks a lot for the hint!

 
  ‹‹ Phonon::VolumeSlider, How to change - adjust volume programmatically?      emptying a sql table model (or a table view) ››

You must log in to post a reply. Not a member yet? Register here!