Results 1 to 4 of 4

Thread: How to show a wizard before the main window?

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

    Question How to show a wizard before the main window?

    Hi,

    how can make the wizard show up alone, and then when it finishes, the main window comes up?

    My main.cpp code is this:
    Qt Code:
    1. int main(int argc, char ** argv)
    2. {
    3. QApplication app(argc, argv);
    4.  
    5. MainWindowImpl win;
    6. win.show(); //shows the main window
    7. win.data = new dataBase;
    8. startWizard wizard(&win, &(win.data));
    9. wizard.show(); //shows the wizard
    10.  
    11. app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
    12. return app.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 


    thanks a bunch for the help,
    david

  2. #2
    Join Date
    Feb 2009
    Location
    China
    Posts
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to show a wizard before the main window?

    Quote Originally Posted by dcopeto View Post
    Hi,

    how can make the wizard show up alone, and then when it finishes, the main window comes up?

    My main.cpp code is this:
    Qt Code:
    1. int main(int argc, char ** argv)
    2. {
    3. QApplication app(argc, argv);
    4.  
    5. MainWindowImpl win;
    6. win.show(); //shows the main window
    7. win.data = new dataBase;
    8. startWizard wizard(&win, &(win.data));
    9. wizard.show(); //shows the wizard
    10.  
    11. app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
    12. return app.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 


    thanks a bunch for the help,
    david
    Maybe this is what you need.

    It wiil be simple if you use exec() for wizard. Mainwindow will show behind wizard, but not activated.
    Qt Code:
    1. int main(int argc, char ** argv)
    2. {
    3. QApplication app( argc, argv );
    4. MainWindowImpl win;
    5. win.show();
    6. app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
    7.  
    8. startWizard wizard;
    9. wizard.exec();
    10. return app.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 

    Also maybe this might be what you want, but this will be a little bit complicated.
    I haven't tested yet.
    In startWizard class:
    Qt Code:
    1. #include "mainwindowimpl.h"
    2. #include <QtGui>
    3.  
    4. Class startWizard : public QWizard
    5. {
    6. public:
    7. startWizard(MainWindowImpl *mainWindow);
    8. ~startWizard();
    9. ...
    10. ...
    11. private:
    12. MainWindowImpl *m_mainWindow;
    13. };
    To copy to clipboard, switch view to plain text mode 
    In startwizard.cpp:
    Qt Code:
    1. startWizard::~startWizard()
    2. {
    3. mainWindow->show();
    4. }
    5.  
    6. startWizard::startWizard(MainWindowImpl *mainWindow)
    7. {
    8. m_mainWindow = mainWindow;
    9. }
    To copy to clipboard, switch view to plain text mode 

    In main.cpp:
    Qt Code:
    1. int main(int argc, char ** argv)
    2. {
    3. QApplication app( argc, argv );
    4.  
    5. MainWindowImpl win;
    6.  
    7. startWizard wizard(&win);
    8. wizard.exec();
    9. return app.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    I don't know if it helps.

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

    dcopeto (27th March 2009)

  4. #3
    Join Date
    Jan 2007
    Posts
    201
    Thanks
    22
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to show a wizard before the main window?

    Qt Code:
    1. int main(int argc, char ** argv)
    2. {
    3. QApplication app(argc, argv);
    4.  
    5. MainWindowImpl win;
    6. win.show(); //shows the main window
    7. win.data = new dataBase;
    8. startWizard wizard(&win, &(win.data));
    9. wizard.show(); //shows the wizard
    10.  
    11. app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
    12. return app.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 
    what you need to do is

    include your startWizard .h to your main.cpp

    after that you need to
    Qt Code:
    1. startWizard sss;
    2. sss.exec();
    To copy to clipboard, switch view to plain text mode 

    than continue to your main window

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

    Talking Re: How to show a wizard before the main window?

    Hey thanks a lot ccp!! what you said worked!

    I just had to put the m_mainWindow->show(); in my startWizard::accept() function instead of in the ~startWizard() like you suggested.


    Thanks a lot!
    Cheers,
    david

Similar Threads

  1. How to show two main windows?
    By Althor in forum Newbie
    Replies: 4
    Last Post: 13th October 2008, 08:30
  2. minimizing main window
    By eric in forum Qt Programming
    Replies: 4
    Last Post: 28th November 2007, 16:54
  3. Problem hiding main window on minimize
    By bpetty in forum Newbie
    Replies: 5
    Last Post: 18th September 2007, 17:41
  4. show() in central main window
    By ufo-vl in forum Newbie
    Replies: 3
    Last Post: 28th July 2007, 02:33
  5. cannot make a main window modal
    By Dark_Tower in forum Qt Programming
    Replies: 12
    Last Post: 23rd March 2006, 10:21

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.