You can do it any way you see fit. C++ allows for many solutions to this problem. For instance each page has a pointer to the wizard object it is part of.
You can do it any way you see fit. C++ allows for many solutions to this problem. For instance each page has a pointer to the wizard object it is part of.
"For instance each page has a pointer to the wizard object it is part of. "
you mean wizard() ?
Qt Code:
class myWizard : public QWizard { Q_OBJECT public: whatever* m_member; } in the myWizard constructor i do : addPage( new myPage1( ) ); wizard()->m_member ? (is this supposed to work?) (apparently it doesnt) (thats basically what i want :D ) }To copy to clipboard, switch view to plain text mode
Can I reimplement ::next ? http://doc.trolltech.com/4.5/qwizard.html#next [slot] (doesnt say virtual, but I'm no c++ expert)
I do realise your time is more precious than mine, so I *am* thankful.
Last edited by BillGates; 6th May 2010 at 18:07.
Yes, you can cast it to a proper type and use your methods.
Qt Code:
MyWizard *wiz = qobject_cast<MyWizard*>(wizard()); // or static_cast if MyWizard doesn't have Q_OBJECT macro wiz->something();To copy to clipboard, switch view to plain text mode
Reimplement nextId().Can I reimplement ::next ? http://doc.trolltech.com/4.5/qwizard.html#next [slot] (doesnt say virtual, but I'm no c++ expert)
BillGates (6th May 2010)
Thanks so much for the code snippet, I didnt find this anywhere, in no example! Perhaps they considered normal people would know this..(qobject_cast). I had no clue that that must be done :< Thank you
About ::next(), I understand you are saying to Not reimplement ::next, but reimplement ::nextId() instead. I want to do some stuff when the user clicks "next" so ::next() seems more intuitive.. Basically, you are saying to "do some stuff" not in ::next but in ::nextId() ?
Qt Code:
i was thinking void myWizard::next() { ..do some stuff... QWizard::next(); } is this wrong in any way ?To copy to clipboard, switch view to plain text mode
PS: apparently if I do in myWizard constructor :
setButton(QWizard::NextButton, mybuton);
connect ( mybuton, SIGNAL(clicked()), this, SLOT(my_slot()));
my_slot() is executed AFTER the next Page's initializePage() ?!?! (is this logical?)
Last edited by BillGates; 6th May 2010 at 21:33.
It's there in many places, I assure you.
No, in that case you need to reimplement QWizardPage::initializePage() on the next page you want to show.About ::next(), I understand you are saying to Not reimplement ::next, but reimplement ::nextId() instead. I want to do some stuff when the user clicks "next" so ::next() seems more intuitive..
Yes, it's logical.PS: apparently if I do in myWizard constructor :
setButton(QWizard::NextButton, mybuton);
connect ( mybuton, SIGNAL(clicked()), this, SLOT(my_slot()));
my_slot() is executed AFTER the next Page's initializePage() ?!?! (is this logical?)
Read this article, it might help you understand how wizards work:
http://doc.trolltech.com/qq/qq22-qwizard.html
ok, i dont know if this is normal or not.... but apparently after casting i cannot access data members of wiz-> or even methods of wiz that themselves access members of the wizard object. I get a SIGSEGV upon running the program...(tried with static_cast too, although i have the q_object macro)
Check if wizard() doesn't return 0 or that qobject_cast doesn't return 0.
Qt Code:
in myPage1 constructor: qDebug()<< this->wizard() ; // outputs QObject(0x0) myWizard *wiz = qobject_cast<myWizard*>( wizard() ); //also tried myWizard *wiz = qobject_cast<myWizard*>((myWizard*) wizard() ); if(wiz) { wiz->my_slot("testing") ; //does not get executed }To copy to clipboard, switch view to plain text mode
i set the Page in the myWizard constructor using : addPage( new myPage1( ) );
What am i screwing up?
Before you add the page to the wizard (which happens after the page constructor is executed) the page doesn't belong to the wizard so wizard() returns 0.
BillGates (7th May 2010)
I am so ashamed of myself. I am a complete idiot. I will give up programming and go be a janitor... Qt is great though....
Bookmarks