Results 1 to 8 of 8

Thread: using *.ui file with QWizard

  1. #1
    Join Date
    Jan 2016
    Posts
    4
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default using *.ui file with QWizard

    Hi all,

    I have used QDesigner to create the *.ui file,
    can you please help with some example how to use that *.ui file and show the QWizard in it?

    I was unable to find any example of such using only creating whole QWizard by code, not by *.ui

    Many Thanks.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: using *.ui file with QWizard

    For each page, derive a class from QWizardPage. In that class, add the UI class either by multiple inheritance, a member variable, or a member variable pointer. In the QWizardPage class constructor, call setupUi( this ) as appropriate for the way you have added the UI class.

    See the Qt examples for writing a custom QDialog or QWidget using Qt Designer. The procedure is exactly the same, only you use QWizardPage as the base class instead of QDialog or QWidget.

    You then call QWizard::addPage() to put your customer page into the wizard.

  3. #3
    Join Date
    Jan 2016
    Posts
    4
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: using *.ui file with QWizard

    hi d_stranz,

    I already have all the pages in the *.ui file

    do not need to call QWizard::addPage() to do what already is in the *.ui file

    how can I use the pages for QWizard from the *.ui file?

    Thanks

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: using *.ui file with QWizard

    Maybe this previous post will help you. I do not know which version of Qt it uses; if it is Qt 4, then some of the include files and modules in the .pro file might have changed.

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: using *.ui file with QWizard

    If you created a wizard in designer, i.e. you have a single .ui file and that contains all pages of the wizard, then you do the same thing you would do for any normal dialog or widget.

    E.g. create a QWizard derived class, add the generated class as a member and call "setupUi(this)" in the constructor.

    Cheers,
    _

  6. #6
    Join Date
    Jan 2016
    Posts
    4
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: using *.ui file with QWizard

    @anda_skoa

    I have tried your recommendation, yet there is error:

    .../widget.cpp:9: error: no matching function for call to 'Ui::Widget::setupUi(Widget* const)'
    ui->setupUi(this);
    ^

    I have done just that: create new Widget project and add and change the *.ui file with QWizard
    I am sorry, I have no idea what I am missing,
    Can you please give me some hint? Thanks

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: using *.ui file with QWizard

    This is from memory so forgive me if it is not perfect

    Pro file
    Qt Code:
    1. ...
    2. HEADERS += wizard.h
    3. SOURCES += wizard.cpp
    4. FORMS += wizard.ui
    5. ...
    To copy to clipboard, switch view to plain text mode 
    Wizard.h
    Qt Code:
    1. ...
    2. namespace Ui {
    3. class Wizard;
    4. };
    5.  
    6. class Wizard: public QWizard
    7. {
    8. Q_OBJECT
    9. public:
    10. Wizard(QWidget *p = 0);
    11. ~Wizard();
    12. ...
    13. private:
    14. Ui::Wizard *ui;
    15. }
    To copy to clipboard, switch view to plain text mode 
    Wizard.cpp
    Qt Code:
    1. #include "wizard.cpp"
    2. #include "ui_wizard.h"
    3.  
    4. Wizard(QWidget *p):
    5. QWizard(p),
    6. ui(new Ui::Wizard)
    7. {
    8. ui->setupUi(this);
    9. }
    10.  
    11. ~Wizard()
    12. {
    13. delete ui;
    14. }
    To copy to clipboard, switch view to plain text mode 
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

  8. #8
    Join Date
    Jan 2016
    Posts
    4
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: using *.ui file with QWizard

    Thank you very much @ChrisW67 !!!

    Just to save some little debugging to the future,
    here is tested code fore someone else just to copy & paste.

    wizadr.h
    Qt Code:
    1. #include <QWizard>
    2.  
    3. namespace Ui {
    4. class Widget;
    5. }
    6.  
    7. class Wizard : public QWizard
    8. {
    9. Q_OBJECT
    10.  
    11. public:
    12. explicit Wizard(QWidget *parent = 0);
    13. ~Wizard();
    14.  
    15. private:
    16. Ui::Widget *ui;
    17. };
    To copy to clipboard, switch view to plain text mode 

    wizard.cpp
    Qt Code:
    1. #include "wizard.h"
    2. #include "ui_wizard.h"
    3.  
    4. Wizard::Wizard(QWidget *parent) :
    5. QWizard(parent),
    6. ui(new Ui::Widget)
    7. {
    8. ui->setupUi(this);
    9. }
    10.  
    11. Wizard::~Wizard()
    12. {
    13. delete ui;
    14. }
    To copy to clipboard, switch view to plain text mode 

    Thanks again everyone for help.

Similar Threads

  1. QWizard fit
    By baray98 in forum Qt Programming
    Replies: 7
    Last Post: 14th November 2010, 17:27
  2. QWizard
    By rmagro in forum Qt Programming
    Replies: 1
    Last Post: 20th October 2009, 17:12
  3. Help with QWizard
    By afflictedd2 in forum Qt Programming
    Replies: 3
    Last Post: 14th April 2009, 22:23
  4. QWizard
    By rmagro in forum Qt Programming
    Replies: 8
    Last Post: 26th September 2008, 21:41
  5. QWizard
    By steg90 in forum Qt Programming
    Replies: 6
    Last Post: 14th December 2007, 10:37

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.