PDA

View Full Version : How to run Qt programs----simple one



shamik
18th November 2006, 07:41
hii all friends

this is really very simple question but its quite irritating when it doesnt run.

i want to know the correct way to run Qt projects or simple ui files with kdevelop.
this is what is want..

I create a project file with atleast one dialog. then on the shell i type the command:
qmake project.pro
make

fine. the exe is made and the project runs ok.

the files which i get after running the qmake and make on the project file in that particular directory are : .exe , form1.ui , form.ui~ , main.cpp , main.cpp~ , .pro , Makefile

the exe is running as required.
but tell me is it necessary that qmake and make should also have generated *.o and *.moc files or moc_* kind of files.
if yes then how can i do so and where is the fault. why it is not getting generated.

and if not then tell me is it necessary to get these files to make this project running in kdevelop??

plz tell me how can i run the qt project in kdevelop. I use kdevelop 2.1 and qt3.3.0

the KAppWizard under project->new gives---> Qt-sdi.

please explain step by step process.
gmail--> shahshamiks@gmail.com 4 chat

thanks and regards.
shamik

e8johan
18th November 2006, 14:03
I think that qmake uses hidden directories for this. Try ls -la

shamik
20th November 2006, 04:51
hii

i tried ls -la but none of *.o of moc_*.* is getting listed. i think there is no use of it. these files are not present in any of the internal directories. they are present in the directory where project file and make file are present.

but first of all tel me are these files really necessary to get the program running in kdevelop ? actually without these files the project is running fine but only from the shell.
this question arises because i have a sample project which has got these files and it is running fine in kdevelop. the thing is that i have not created that project so i dont know the actual procedure.

i think these files should get generated automatically whenever the project is compiled.
what say?


regards.
shamik

wysota
20th November 2006, 05:58
It's not possible that there are no .o files. Your executable is formed from them. There could be a .obj directory and all the object files (one for each cpp file in the project) should be there.

shamik
20th November 2006, 11:55
hii

the moc and *.o files are getting created but only when the project compiles completely without any errors.

thats fine.

but the project is still not running. I already had qt 3.1 installed bydefault with RH9.
then i installed qt 3.3.0 manually and have set the path variables. when i type the set command it shows the new installation path i.e. /usr/local/qt/bin ... etc ....thats ok.

when i type which moc and which uic and which qmake then it shows the new one i.e. /usr/local/qt/bin/moc , /usr/local/qt/bin/uic, /usr/local/qt/bin/qmake....that is also ok.

but when i compile or configure or make the kdevelop project then it takes /usr/lib/qt-3.1 files.
something like this..
checking for moc...../usr/lib/qt-3.1/bin/moc
checking for uic...../usr/lib/qt-3.1/bin/uic ...........etc.


that means kdevelop still takes the old qt file's paths.
but i have already set the necessary environment variables. when i compile any project file i.e. *.pro of qt using qmake in the shell then it normally takes the new qt path.

then why cant kdevelop do so??
if kdevelop starts taking the new qt path then i think the problem should get solved. can u please tell me how should i do it ?

safknw
20th November 2006, 13:00
Only *.exe is required. *.o and *.moc is generated during compilation.

wysota
20th November 2006, 13:29
then why cant kdevelop do so??
if kdevelop starts taking the new qt path then i think the problem should get solved. can u please tell me how should i do it ?

The easiest way (that's how I often do it) is to set the path as a custom environment variable inside the project configuration. Alternatively, you cat set the path in your user profile, so that kdevelop always picks the right path or you can create a custom desktop icon for kdevelop and modify its properties and set the path there.

shamik
21st November 2006, 13:09
i m trying to set those library path through project->options->linker

then i uncheck the qt checkbox and manually give the following paths :
/usr/local/qt/include /usr/local/qt/bin /usr/local/qt/lib /usr/local/qt/bin/uic /usr/local/qt/bin/moc


but still while configuring it again takes moc and uic paths as /usr/lib/qt3.1/bin

and after adding all these paths when i make the project it gives hell lot of errors.

my main aim is to run the Qt GUIs through kdevelop. this is what i have done-->
1. i created a new project Qt Sdiwithout source and headers.
2. then file->new->*.ui and gave it a name called KTestDlg.ui ( as explained in the manual).
3. then Qt opened and i added a push button.......created a new slot called pbclicked() and under it i wrote a small code to show a messagebox. I am sure it has got no errors.....(save). now i can view this file under "Interfaces" folder.

4. then going back to kdevelop i created new class called KTest and under base class i wrote "KTestDlg" without quotes and checked the checkbox against 'generate a QWidget child class'.
5. the KTestDlg class gets created with its constructor and destructors and the KTest.h file which has got nothing but only the declaration of these constructors and destructors.

6. then in the main file i make object of this class KTest as kk and just kk.show() shows the form with the pushbutton widget.
7. but the slot which i had written for it under the ui.h file in Qt is not getting called. instead either close() is the slot or nothing happens at all after clicking this pushbutton.

8. i think the .h file of KTest class i.e. KTest.h should be the one similar to KTestDlg.h which is getting generated automatically. This .h file is the original ui.h file written in Qt i.e. KTestDlg.ui.h

9. on the heading of the file KTestDlg.h which kdevelop shows is written that this file has been generated after reading KTestDlg.ui by the uic and it is created by Qt 3.1.1
which is the older version.

I know it is becoming quite messy. but read it carefully it is easy to visuallize the situation from this long description.

please tell me the write procedure if i am going wrong anywhere.
the slots declared in Qt are not shown in KTest class as functions. I think this KTest class should show the slots and all the funtions of KTestDlg.ui.h written in Qt as its function since it is inheriting it.

please tell me. i have tried out all the possible combinations of it hoping that trial and error might lead to some solution but dint worked.

y the KTest class cant show the slots as its functions. and y the slot of every pushbutton becomes either close() or happens nothing bydefault and the original one declared is not called eventhough the compiler is linking KTestDlg.h dynamically.


thanks and regards.
shamik
:eek:
:confused:
:crying:

wysota
21st November 2006, 13:35
It's in "Make options". Add an environment variable PATH and set it to "/your/qt4/installation/bin:$PATH".

shamik
22nd November 2006, 09:52
hiii alll


thankyou very much for the help

i have now solved the problem myself. the answere to what i asked is nowhere in this thread but anyhow i managed to solve it.

thanks everybody for trying to help me.

regards..
shamik:cool:

sunil.thaha
23rd November 2006, 07:29
It would help if you could state what the real problem was and How you managed to solve it ;)

shamik
23rd November 2006, 10:08
I was trying out different combinations of solving this problem and finally i got one which worked. and i think this is the correct method because every project file which i create is now working fine. here it goes.


i made a qt project .pro and compiled it, made the exe by running make. the exe should run as desired.

now there are three hidden folders in the folder where u create this .pro file.
amongst these is one called .ui

from terminal, go to the folder where ur .pro file is and then type the command--- mv .ui ui

now u can view this folder from the GUI. now copy the files inside this folder outside of it i.e. to the folder where ur .pro file . (actually this is not required but u can do it.....adding files to kdevelop becomes easy).

now open kdevelop newly created project and click on project->add existing files

then go to this folder where ur .pro file is. then add the files ending with .ui and .ui.h and .h

kdevelop will automatically create the class and place the files in their proper locations.
what else?
configure it and make it

enjoy running the exe.

sometimes we can solve the problem without anybody's help

right !?! hai na bhaiya?? (i cannot mention the name but the one who reads can understand it) :p


regards
shamik :)

wysota
24th November 2006, 09:58
Wouldn't it be simpler just to show hidden files from your file manager? Or delete the entries from your project file enabling the use of ui, object and moc dirs?

Besides, these folders are hidden on purpose - you don't need to even know what's inside them and they are hidden so that they don't clutter your view. But if you want to always see them, then good for you!