Monday, August 17, 2009

My Qt Experience

Qt is a quick UI protyping tool. You used this in your university days to get
the presentation logic going. Thanks for Sujeeth and Sreenivas N Keeni for pursuing
and encouraging use of Open technologies. And definitely an advantage since it works on Linux and a de-facto platform for servers-class machinces.

Often I find that you would create a ui file but struggle to get build steps and
generate executable. Here goes the steps.

Step 0:
Ensure uic, moc and g++ is on your path doing which on each of these executeables

Step 1:
uic -o project.h project.ui

Step 2:
uic -i project.h -o project.cpp project.ui

Step 3:
moc -o moc_project.cpp project.h

Step 4:
if in your ui file you have renamed Form1 to something else (like in here it is MyForm) make appropriate changes
Ensure file main.cpp exists

And main.cpp :
-----
cat main.cpp
#include "qapplication.h"
#include "project.h"

int main(int argc, char* argv[])
{
QApplication app(argc,argv);
Form1 f1;
app.setMainWidget(&f1);

f1.show();
return app.exec();

}
----

Step 5:
Generate executable:

g++ -o test -I$QTDIR/include -L$QTDIR/lib main.cpp project.cpp moc_project.cpp -lkdevelop
NOTE : the link option that worked in Redhat 7.2 was -lqt , on RHEL I had to use -lkdevelop

Step 6:
this should have created Linux executable named test.
Run it ./test

Time to enjoy.

Followers