Results 1 to 9 of 9

Thread: Multi Window Application in QT/C++

  1. #1
    Join Date
    Sep 2007
    Posts
    36
    Thanks
    5
    Thanked 3 Times in 1 Post

    Default Multi Window Application in QT/C++

    I want to create a simple accounting software.

    It has a main window with all the menus and other windows for making vouchers, stock, etc..

    The main window is main.cpp and other files will be xyz.cpp ,etc.

    How do I go about with the application ?

    Lets say I click on the "Create ledger" tool button.

    Then how do I link the ledger.cpp file and show the Ledger creation dialog ??

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Multi Window Application in QT/C++

    Have you heard of header files? Please learn at least basics of C++ first, then try to use Qt...

    See FAQ: I have two forms. How to open a second form after a button is clicked in the first one?
    J-P Nurmi

  3. #3
    Join Date
    Sep 2007
    Posts
    36
    Thanks
    5
    Thanked 3 Times in 1 Post

    Default Re: Multi Window Application in QT/C++

    Sorry for not RTFM. I have bought 2 books on QT and none of them explain how to use QT Designer and I spend days figuring it out how to do it.

  4. #4
    Join Date
    Sep 2007
    Posts
    36
    Thanks
    5
    Thanked 3 Times in 1 Post

    Default Re: Multi Window Application in QT/C++

    What if I have both the forms designed in QT Designer.

  5. #5
    Join Date
    Sep 2007
    Posts
    36
    Thanks
    5
    Thanked 3 Times in 1 Post

    Default Re: Multi Window Application in QT/C++

    Any good docs on using QT Designer ?

    I have created the Menubar in QT Designer and I want that on clicked it calls a function ShowGroups()

    How do I access the menubar items created in designer in the .cpp files ?

    ps : should I dump the designer and just hand code everything ?? I cant find any good docs for designer...


  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Multi Window Application in QT/C++

    J-P Nurmi

  7. #7
    Join Date
    Sep 2007
    Posts
    36
    Thanks
    5
    Thanked 3 Times in 1 Post

    Default Re: Multi Window Application in QT/C++

    I read the manual but I still cant figure out how to load the 2nd form.

    I have two forms
    1. mainwindow.ui
    2. groupwindow.ui

    Below are the files..
    main.cpp
    Qt Code:
    1. #include "ui_mainwindow.h"
    2. //Main program
    3. int main(int argc, char *argv[])
    4. {
    5. QApplication app(argc, argv);
    6. Ui::MainWindow ui;
    7. QMainWindow *mainwindow = new QMainWindow;
    8. ui.setupUi(mainwindow);
    9. mainwindow->show();
    10. return app.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 
    mainwindow.h
    Qt Code:
    1. class MainWindow : public QMainWindow, private Ui::MainWindow, private Ui::GroupWindow
    2. {
    3. Q_OBJECT
    4. public:
    5. MainWindow(QWidget *parent = 0);
    6. void InitMenu();
    7. public slots:
    8. void OpenGroupWindow();
    9. };
    10. #endif
    To copy to clipboard, switch view to plain text mode 
    mainwindow.cpp
    Qt Code:
    1. #include "ui_mainwindow.h"
    2. #include "mainwindow.h"
    3. #include "ui_groupwindow.h"
    4.  
    5. MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
    6. {
    7. InitMenu();
    8. }
    9.  
    10. void MainWindow::InitMenu()
    11. {
    12. //groupAction is a menu action in the ui file.
    13. connect(actionGroup, SIGNAL(clicked()), this, SLOT(OpenGroupWindow()));
    14. // Nothing happens when I click / triggered the above menu item. The application compiles without any errors.
    15. }
    16.  
    17. void MainWindow::OpenGroupWindow()
    18. {
    19. QWidget *widget = new QWidget;
    20. Ui::GroupWindow gwui;
    21. gwui.setupUi(widget);
    22. setCentralWidget(widget);
    23. widget->show();
    24. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jpn; 8th July 2008 at 17:33. Reason: missing [code] tags

  8. #8
    Join Date
    Sep 2007
    Posts
    36
    Thanks
    5
    Thanked 3 Times in 1 Post

    Default Re: Multi Window Application in QT/C++

    ok I am trying out few other things..I will post back if it doesnt work,...

  9. #9
    Join Date
    Sep 2007
    Posts
    36
    Thanks
    5
    Thanked 3 Times in 1 Post

    Default Re: Multi Window Application in QT/C++

    Ook Got It Working !! :d

Similar Threads

  1. QSkinWindows Classes
    By kernel_panic in forum Qt-based Software
    Replies: 45
    Last Post: 20th April 2010, 12:35
  2. Customize Application Window
    By fruzzo in forum Qt Programming
    Replies: 5
    Last Post: 4th July 2008, 05:20
  3. Replies: 6
    Last Post: 3rd May 2007, 15:17
  4. Independant window in an application
    By titoo in forum Qt Programming
    Replies: 4
    Last Post: 28th February 2007, 11:07
  5. Replies: 0
    Last Post: 21st February 2006, 16:30

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.