Qt4 on Kubuntu (getting started)

Qt logo

Yesterday I decided to investigate Qt from Trolltech and get something working with it.

Very briefly, Qt is a library that allows you to create interfaces. Lots of programs use it (a lot of KDE programs do) and i’ve heard a lot of good things about it but alway thought naaa, this is too complicated. So yesterday i downloaded all the libraries of Qt4 (Qt4 is free for open-source development) and tired a tutorial and … it wouldn’t work – I got some error messages saying that it wouldn’t recognise some libraries (qapplication.h: No such file or directory)!

What the hell had I got wrong?
Actually I don’t know. I had installed most of the Qt4 stuff in adept I deemed necessary but it seems that I had not installed all Qt4 stuff (in my foolishness I tried removing some Qt3 stuff – somethin not to do – and it removed amarok as a result. Had to reinstall it).
After installing all (or most) of the Qt4 stuff it worked and I was really surprised as to how easy it is to create interface code.

qt adept

The best tutorial is I think on the Qt website.

Getting started

First of all get all (or most) of the Qt4 stuff in adpet installed.

Then type the following code that is available from tutorial 1:

 #include <QApplication>
#include <QPushButton>

int main(int argc, char *argv[])
QApplication app(argc, argv);

QPushButton hello("Hello world!");
hello.resize(100, 30);

return app.exec();

Then save the file as (for example) main.cpp.

Next at the prompt type:

$qmake -project (creates a .pro file)
$qmake (creates a platform specific makefile)
$make (calls the makefile and produce the exe)

Run the exe to get your first app working. It’s really easy.

Have Fun and Tranks Trolltech!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s