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 2009
    Location
    Portugal
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

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

    Hi!

    I'm using a QWizard to get some user configurations at the beggining of my program but i can't seem to find a way to fill in my database class with the data the user enters in the wizard pages! How can this be done?


    thanks a lot for the help,
    david

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

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

    Hi,

    have a look at the docs, there you can find your questions answered: Class Wizard Example. Especially "void ClassWizard::accept()".

    Or in your code is somewhere
    Qt Code:
    1. MyWizard wiz;
    2. wiz.exec()
    3. wiz.getMyFancyData(); // where you have to implement these function in your wizard class...
    To copy to clipboard, switch view to plain text mode 

    Lykurg

  3. #3
    Join Date
    Feb 2009
    Location
    Portugal
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

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

    Thanks for the reply


    Yeah in the meantime i found that too and my problem changed:
    From what i understood, one recovers the data using something like

    Qt Code:
    1. QString sessionName = field("session.name").toString();
    To copy to clipboard, switch view to plain text mode 

    which is ok. My problem is that i want to recover data from a QTableWidget! Any ideas on how to do this?


    thanks for your help,
    david

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

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

    The "field" way is only one possibility. Since the QWizard is a normal class you can simply add a private member which points to the table. Use this pointer in the "save" function to get the data.

  5. #5
    Join Date
    Feb 2009
    Location
    Portugal
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

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

    Maybe i didn't give you enough details because i'm having trouble finding out to do that...


    This is what i have in my startwizard.h
    Qt Code:
    1. class startWizard : public QWizard
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. enum{Page_Intro, Page_New, Page_Load, Page_Configs, Page_LoadDetails, Page_NewDetails};
    7. startWizard(QWidget *parent = 0);
    8.  
    9. void accept();
    10.  
    11. };
    12.  
    13. (...)
    14.  
    15. class configsPage : public QWizardPage
    16. {
    17. Q_OBJECT
    18.  
    19. public:
    20. configsPage(QWidget *parent = 0);
    21. int nextId();
    22.  
    23. private:
    24. (...)
    25. QTableWidget *tableDisplay;
    26.  
    27. (...)
    28. };
    To copy to clipboard, switch view to plain text mode 

    In the ConfigsPage of the wizard i create the table for the user to see what he's adding/configuring and then i want to be able to recover the data he just entered to my database object in the main application.

    In your previous reply you meant placing a QTableWidget pointer in the startWizard class, pointing to the table that gets the stuff in ConfigsPage class? even that i'm having trouble with...

    I still don't see how can i go on from there? I mean to have access to the database I must make the wizard have access to the database somehow...


    thanks a lot for the help,
    david

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    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?

    Move the table widget pointer to your QWizard subclass and then access the pointer when you want to retrieve the data.
    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
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

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

    Qt Code:
    1. class startWizard : public QWizard
    2. {
    3. Q_OBJECT
    4. public:
    5. enum{Page_Intro, Page_New, Page_Load, Page_Configs, Page_LoadDetails, Page_NewDetails};
    6. startWizard(QWidget *parent = 0);
    7. void accept();
    8. private:
    9. configsPage *m_configsPage;
    10. };
    11.  
    12. startWizard::startWizard(QWidget *parent) : QWizard(parent) {
    13. //...
    14. m_configsPage = new configsPage(this);
    15. addPage(m_configsPage);
    16. //...
    17. }
    18.  
    19. void startWizard::accept() {
    20. //...
    21. m_configsPage->table() //<- here's your pointer...
    22. //...
    23. }
    24. (...)
    25.  
    26. class configsPage : public QWizardPage
    27. {
    28. Q_OBJECT
    29.  
    30. public:
    31. configsPage(QWidget *parent = 0);
    32. int nextId();
    33. const QTableWidget* table() const {return tableDisplay;}
    34.  
    35. private:
    36. (...)
    37. QTableWidget *tableDisplay;
    38.  
    39. (...)
    40. };
    To copy to clipboard, switch view to plain text mode 

  8. The following user says thank you to Lykurg for this useful post:

    dcopeto (27th March 2009)

  9. #8
    Join Date
    Feb 2009
    Location
    Portugal
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Talking Re: How to transfer data entered in a QWizard to other classes? (SOLVED)

    THANK YOU!

    That took care of my table access and now I have also managed to 'reach' the dataBase from the wizard by passing a pointer to the database to it!

    thanks again,
    david

  10. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    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? (SOLVED)

    You don't have to transfer pointers to the database (assuming you are using QSqlDatabase). You can always retrieve the connection by calling it by name. See docs of QSqlDatabase.
    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.


  11. #10
    Join Date
    Feb 2009
    Location
    Portugal
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

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

    Hey! thanks for the suggestion! I'm not using sqlDatabase, I'm using my own storing class, because it's not a lot of stuff, anyway can you tell me when does it 'payoff' to use a sql database instead of a custom class? I'm not really into it so it's probable that I'm writing garbage right this moment...


    thanks,
    david

  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?

    hi

    maybe i didnt understand very well the method that Lykurg wrote in code, but, will other Pages of the wizard be able to access m_configsPage->table() ?

    Is it possible to pass objects instead of int/Qstrings using ::field() and registerField(..) ?

  13. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    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?

    You can pass anything that will fit into QVariant.
    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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.