Results 1 to 7 of 7

Thread: source and implementation

  1. #1
    Join Date
    Mar 2006
    Posts
    8
    Thanks
    5
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default source and implementation

    hey i have created a form ok then i generated the source using uic. In the form itself i have implemented slot and signals. now i have three file form1.ui,form1.h and form1.cpp.
    now i want to have the instance of it in my main.cpp . so that i can produce an executable.
    what shud i need to do.
    plz help me
    if possible give me a snippet of code

  2. #2
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: source and implementation

    Quote Originally Posted by shrikarcse
    hey i have created a form ok then i generated the source using uic. In the form itself i have implemented slot and signals. now i have three file form1.ui,form1.h and form1.cpp.
    now i want to have the instance of it in my main.cpp . so that i can produce an executable.
    what shud i need to do.
    plz help me
    if possible give me a snippet of code
    what version of QT you are using... and platform used...

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

    shrikarcse (28th March 2006)

  4. #3
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: source and implementation

    you create an object of ur form class in the main and then call the UI function of it, which sould enable the display of the ui..

    Then make it form_obj->show();

    main.cpp
    Qt Code:
    1. int main(int argc,char *argv[])
    2. {
    3. QApplication app(argc,argv);
    4. app.setQuitOnLastWindown(true);
    5.  
    6. QMainWindow *form = new QMainWindow;
    7. Ui::MainWindow ui;
    8. ui.setupUi(form);
    9.  
    10. form->show();
    11. return app.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 

    then execute ur project...

  5. #4
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: source and implementation

    Quote Originally Posted by Kapil
    you create an object of ur form class in the main and then call the UI function of it, which sould enable the display of the ui..

    Then make it form_obj->show();

    main.cpp
    Qt Code:
    1. int main(int argc,char *argv[])
    2. {
    3. QApplication app(argc,argv);
    4. app.setQuitOnLastWindown(true);
    5.  
    6. QMainWindow *form = new QMainWindow;
    7. Ui::MainWindow ui;
    8. ui.setupUi(form);
    9.  
    10. form->show();
    11. return app.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 

    then execute ur project...
    Its validate only for Qt4...

    You dont must use uic. Use qmake for bulding your project.

    1) subclass you form class

    Qt Code:
    1. /////// formnew.h
    2.  
    3. #include "from1.h"
    4. class FormNew::Form1()
    5. {
    6. }
    To copy to clipboard, switch view to plain text mode 

    2) write main app function

    Qt Code:
    1. #include "formnew.h"
    2. int main( int argc, char ** argv )
    3. {
    4. QApplication a( argc, argv );
    5.  
    6. QFormNew frm;
    7. a.setMainWidget(&frm);
    8. frm.show();
    9.  
    10. a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
    11. return a.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 

    3) read about qmake
    a life without programming is like an empty bottle

  6. The following user says thank you to zlatko for this useful post:

    shrikarcse (28th March 2006)

  7. #5
    Join Date
    Mar 2006
    Posts
    8
    Thanks
    5
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default how to generate source using qmake

    hey is there a way to generate the source from the *.ui form using qmake.
    as far as i know qmake is used to generate the makefile when the .cpp and .h files are present.

    but i want really is the generation of those .cpp and .h files from qmake
    help needed

  8. #6
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: how to generate source using qmake

    a life without programming is like an empty bottle

  9. #7
    Join Date
    Feb 2006
    Location
    New Delhi,India
    Posts
    226
    Thanks
    14
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: source and implementation

    This information is in support with QT4

    There is no need to create the .h files explicitly by running the "uic" command on *.ui files..
    What you have to do is just include proper file name at the top of your main.cpp.. In QT4 the .h files are auto generated from your ui files...

    for eg. if your ui file is Form.ui then you will have to include-> #include "ui_form.h"..

    after you are done with "qmake", when you run "make" this file is generated...

    try it out and see it urself...

  10. The following user says thank you to Kapil for this useful post:

    shrikarcse (29th March 2006)

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.