Page 2 of 2 FirstFirst 12
Results 21 to 29 of 29

Thread: How to transfer data entered in a QWizard to other classes?

  1. #21
    Join Date
    Feb 2010
    Posts
    24
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Question Re: How to transfer data entered in a QWizard to other classes?

    "For instance each page has a pointer to the wizard object it is part of. "

    you mean wizard() ?

    Qt Code:
    1. class myWizard : public QWizard
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. whatever* m_member;
    7. }
    8.  
    9.  
    10. in the myWizard constructor i do :
    11. addPage( new myPage1( ) );
    12.  
    13.  
    14.  
    15.  
    16.  
    17. myPage1::mypage1(QWidget *parent) : QWizardPage(parent) {
    18.  
    19. wizard()->m_member ? (is this supposed to work?) (apparently it doesnt) (thats basically what i want :D )
    20.  
    21. }
    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.

  2. #22
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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 transfer data entered in a QWizard to other classes?

    Quote Originally Posted by BillGates View Post
    "For instance each page has a pointer to the wizard object it is part of. "

    you mean wizard() ?
    Yes, you can cast it to a proper type and use your methods.

    Qt Code:
    1. MyWizard *wiz = qobject_cast<MyWizard*>(wizard()); // or static_cast if MyWizard doesn't have Q_OBJECT macro
    2. wiz->something();
    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)
    Reimplement nextId().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    BillGates (6th May 2010)

  4. #23
    Join Date
    Feb 2010
    Posts
    24
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to transfer data entered in a QWizard to other classes?

    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:
    1. i was thinking
    2.  
    3. void myWizard::next() {
    4.  
    5. ..do some stuff...
    6.  
    7. QWizard::next();
    8. }
    9. 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.

  5. #24
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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 transfer data entered in a QWizard to other classes?

    Quote Originally Posted by BillGates View Post
    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
    It's there in many places, I assure 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..
    No, in that case you need to reimplement QWizardPage::initializePage() on the next page you want to show.



    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?)
    Yes, it's logical.


    Read this article, it might help you understand how wizards work:
    http://doc.trolltech.com/qq/qq22-qwizard.html
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #25
    Join Date
    Feb 2010
    Posts
    24
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to transfer data entered in a QWizard to other classes?

    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)

  7. #26
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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 transfer data entered in a QWizard to other classes?

    Check if wizard() doesn't return 0 or that qobject_cast doesn't return 0.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #27
    Join Date
    Feb 2010
    Posts
    24
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to transfer data entered in a QWizard to other classes?

    Qt Code:
    1. in myPage1 constructor:
    2.  
    3. qDebug()<< this->wizard() ; // outputs QObject(0x0)
    4.  
    5. myWizard *wiz = qobject_cast<myWizard*>( wizard() ); //also tried myWizard *wiz = qobject_cast<myWizard*>((myWizard*) wizard() );
    6.  
    7. 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?

  9. #28
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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 transfer data entered in a QWizard to other classes?

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. The following user says thank you to wysota for this useful post:

    BillGates (7th May 2010)

  11. #29
    Join Date
    Feb 2010
    Posts
    24
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to transfer data entered in a QWizard to other classes?

    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....

Similar Threads

  1. Default Item View classes and returning data from model
    By xerionn in forum Qt Programming
    Replies: 8
    Last Post: 23rd April 2009, 19:50
  2. Item View classes and returning data !
    By xerionn in forum Newbie
    Replies: 3
    Last Post: 16th January 2009, 08:52
  3. Qcj Data classes initial release
    By croftj in forum Qt-based Software
    Replies: 0
    Last Post: 1st May 2007, 02:51
  4. Replies: 1
    Last Post: 9th March 2007, 21:07
  5. Record update windowd entered data saving
    By MarkoSan in forum Qt Programming
    Replies: 56
    Last Post: 18th January 2006, 18:50

Tags for this Thread

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.