Results 1 to 20 of 29

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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?

    yes, i know its a template, pardon me, a QList<QString> . I didnt think it mattered much.
    I dont understand what you mean by "your wizard class public interface" ? Maybe I am missing something?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 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
    yes, i know its a template, pardon me, a QList<QString> . I didnt think it mattered much.
    Well, it does, because QStringList is already registered to be used with QVariant.

    I dont understand what you mean by "your wizard class public interface" ? Maybe I am missing something?
    I mean two methods in your wizard class's "public" section - one for setting the value and the other for getting it. Look at the code Lykurg has written, "table()" is the getter method and "setTable(QTableWidget*)" would be a setter method.

    Still you didn't answer what you want to do with this all so maybe there are tons of better way to do what you want.
    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. #3
    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 want for the QTableWidget *tableDisplay from the first QWizardPAGE to be accesible to the second, the third and so on Pages. So that i can use them for default values, exacty what the field() does.
    The only problem is that I am not competent enough; I dont know how to pass my own variables through registerField().
    If I have a QStringList created in Page1, i would like to access it in Page2 and Page3..


    in void myPage2::initializePage() {

    myObject list = field("some_field_registered_from_page1") <-- something like this...

    }

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 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
    I want for the QTableWidget *tableDisplay from the first QWizardPAGE to be accesible to the second, the third and so on Pages. So that i can use them for default values, exacty what the field() does.
    It's not what the field() does. To me it seams you need a model in your wizard. Then you can set this model to a QTableView (or QListView) in the first wizard page and also access the model from other pages. field() should represent a single value, not all possible values.
    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.


  5. #5
    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?

    Umh... so how would i access the model from the QWizard class from inside the Pages ? Pass it to their constructor ?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 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?

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


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

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 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.


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

    BillGates (6th May 2010)

  10. #9
    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.

  11. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 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.


  12. #11
    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)

  13. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 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.


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
  •  
Qt is a trademark of The Qt Company.