Results 1 to 20 of 28

Thread: how to launch a wizard from the mainwindow's File Menu

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2013
    Posts
    25
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default how to launch a wizard from the mainwindow's File Menu

    hi all
    i was wondering how i'd go about launching my wizard from the file menu of the mainwindow using the New action in the file menu, so that when i click the New action the wizard is successfully launched.

    here's a snapshot of the main.cpp file

    Qt Code:
    1. #include <QApplication>
    2. #include <QTranslator>
    3. #include <QLocale>
    4. #include <QLibraryInfo>
    5.  
    6. #include "SkoolCalcWizard.h"
    7. #include "mainwindow.h"
    8.  
    9. int main(int argc, char *argv[])
    10. {
    11.  
    12.  
    13. QApplication app(argc, argv);
    14.  
    15. #ifndef QT_NO_TRANSLATION
    16. QString translatorFileName = QLatin1String("qt_");
    17. translatorFileName += QLocale::system().name();
    18. QTranslator *translator = new QTranslator(&app);
    19. if (translator->load(translatorFileName, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
    20. app.installTranslator(translator);
    21. #endif
    22.  
    23. MainWindow window;
    24.  
    25. window.show();
    26.  
    27. return app.exec();
    To copy to clipboard, switch view to plain text mode 

    And here's the part of the mainwindow where i've tried defining the newFile() action to suit my needs

    Qt Code:
    1. void MainWindow::newFile()
    2. {
    3.  
    4.  
    5. SkoolCalcWizard *wizard = new SkoolCalcWizard;
    6. return wizard->exec();
    7.  
    8.  
    9. }
    10.  
    11. void MainWindow::createActions()
    12. {
    13. newAct = new QAction(tr("&New"), this);
    14. newAct->setShortcuts(QKeySequence::New);
    15. newAct->setStatusTip(tr("Create a new file"));
    16. connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
    17. }
    To copy to clipboard, switch view to plain text mode 

    your help will be much appreciated, thanks in advance!!!!!
    Last edited by wysota; 2nd September 2013 at 22:42.

Similar Threads

  1. how to add my menu class to my MainWindow?
    By saman_artorious in forum Qt Programming
    Replies: 3
    Last Post: 14th July 2012, 21:27
  2. Replies: 1
    Last Post: 29th September 2011, 11:14
  3. Launch app by opening a file
    By Windsoarer in forum Qt Programming
    Replies: 2
    Last Post: 28th May 2009, 06:22
  4. Replies: 1
    Last Post: 13th May 2009, 03:18
  5. MainWindow Menu bug in Qt 4.2.3?
    By No-Nonsense in forum Qt Programming
    Replies: 4
    Last Post: 11th March 2007, 11:47

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.