Firefox 2

Qt4 tutorial for absolute beginners

Author, (c): sector at ynet dot sk, please do not copy without permission.

If you have experience with programming in C/C++ (or at least have basic knowledge about principles of object oriented programming) and you want to learn Qt4, this tutorial is for you. This tutorial is especially dedicated to beginners. This tutorial is intended to be more practical than theoretical. It focuses on Qt4, no previous major versions of Qt are discussed here.

The reason why I decided to write this tutorial is that there is real lack of Qt tutorials for real beginners, people who want to start with Qt4 but they just don't know how. Qt documentation is really nice written, however it is hard to understand for average programmer. Examples bundled with Qt distribution are impressive but most of them are very difficult for beginner to learn from.

My first Qt GUI application tested with Qt 4.4.3.

Can an object fall through mass 5 times greater than itself nearly as fast as it would fall through air? (When only force available is gravity?) More..

WTC Twin Towers collapse, did you know that:

Watch technical analysis of WTC collapse by Richard Gage - architect with 20+ years experience with buildings design/construction

Online at Google Video: Architect Richard Gage - How Towers Fell
Direct download of hires 700MB avi: 911.Blueprint.for.Truth.2008.Edition.DVDRip.XviD (2008 Edition)

Table of contents:


Other stuff

Useful links


I want to say a word of thanks to following people for helping me with this tutorial:


30.11.2008 - updated Preparations section to reflect latest changes, Qt4 on Windows can be installed via automated installer, no need to compile anymore

Your comments/feedback/bug/typo/inaccuracy reports or help with writing this tutorial are welcome.
Your feedback is very importat for me. I need to know if writing of this tutorial is worth the effort.

model view
painting with Qt - very simple example
clicking grid like widget

Email   not mandatory ( will be changed to na login [ at ] to prevent spam)

Please comment on QT stuff only on this miniboard. I don't care if you think 9/11 stuff should be included on this page or not, please do not tell me what I should put here or what I should not. Use private mail above for anything else than QT. Thank you.
Robot check, write letters from picture:

Andy Croft   2013-09-27 09:22:47

Thanks! This is just what I need. Project is a remote env.monitoring system, running on a Raspberry Pi.

Guus Bonnema   2013-09-23 17:52:40

Thank you for creating this tutorial, I am certainly going to use it.

John   2013-08-25 22:48:34

You certainly rock. This is exactly what I needed!

kay   2013-05-31 01:47:46


thanks for this very useful tutorial.

joum   2013-04-18 10:20:21

You ROCK, sir!

Good Job!

laurnzo55   2012-09-12 05:24:10

I was searching for a tutorial for QT4 and I found yours; "QT4 tutorial for absolute beginners". Your online tutorial is very nice and a pleasure to learn from. Presentation is very clear and easy to follow. It is an excellent launching point. Thanks for sharing! Do have any recommendations for learning material to continue with?
bc 9/11/2012

shridevi   2012-09-11 10:46:31

I am new to Qt .how to read pixel values and get the intensity values of image in Qt.
How to get size if image.Please help me out with relevant complete code

Thanks in advance..

xieyl   2012-09-03 03:31:17

Thanks. Good :)

Alin   2012-06-14 11:28:42

I have read your articles about Qt.
I installed QT sdk and mingv on Windows 7.
I tried to compile on Windows the simplest Qt program but I did not succeeded.
I did qmake, make.
I got this error (at make command)
Makefile.Debug:58: *** missing separator. Stop.
Please tell me how to compile the program.
My code:

#include <QApplication>
#include <QTextEdit>

int main(int argv, char **args)
QApplication app(argv, args);

QTextEdit textEdit;;

return app.exec();

It is very frustrating for me because the simplest case is not working.
I am looking forward for your answers.
Thank you.

Alin   2012-05-29 16:15:59

Nice documentation.
But I can not compile a simple qt code on windows using ui controls.
I have one cpp file.
I tried steps
1)qmake -project
3) make
Step 3 got errors:
Makefile.Debug:58: *** missing separator. Stop.

My cpp file is:

#include <qapplication.h>
#include <qlabel.h>

int main(int argc, char *argv[])
QApplication app(argc, argv);
QLabel *label = new QLabel("Linux is wonderful", 0);
return app.exec();

Can you halp me to solve this problem ?

Theo   2012-05-15 21:11:50

In the "Drag and Drop" section, you wrote "QList&lt;QUrl&gt; urlList;". That caused me quite a lot of confusion, as it looked like no C++ programming I had ever seen before, until I downloaded your zip file and saw that you meant "QList<QUrl> urlList;". You might want to correct that.

ezekia Matabaro   2012-04-27 16:20:03

Running build steps for project calculator...
Starting: "/usr/bin/qmake-qt4" /usr/lib/qt4/examples/widgets/calculator/ -r -spec linux-g++ CONFIG+=debug
The process "/usr/bin/qmake-qt4" exited normally.
Makefile not found. Please check your build settings
Error while building project calculator (target: Desktop)
When executing build step 'Make'

ezekia Matabaro   2012-04-27 15:46:58

Makefile not found. Please check your build settings
Error while building project calculator (target: Desktop)
When executing build step 'Make'
"any help please some one familia to ubuntu"

Yuanbatou   2012-04-09 11:41:20

Good blog, learned a lot from you

monika tewari   2012-03-19 08:15:00


I need this whole tutorial in pdf format.Please provide me the link......

thanx in advance..

I is urgent

Niren   2012-02-29 13:45:02

Hi, I have a text file i wish to add to my QT4 project, how do i do this?

Ragini   2012-02-29 12:04:29

Ya has a great stuff on this QT Topic thanks for Suggesting efasfsf

efasfsf   2012-02-14 11:15:29

Qt has good tutorials on many website i used to learn on Now i found this better useful stuff here thankss

Shyam   2012-02-04 17:05:08


i am working on control tool(in qt4) for our robotics project. Now we are trying to display feed from our robots in our gui created using Qt4 designer widget we are using is "QGraphicsview". Our structure is as below contains the Gui interface logic created from .ui file using pyuic4) this one inherits from just contains signals and slots for buttons : contains 2 classes one is python specific Node class and other Thread class

following code shows contents
from pk_architecture.pk_util import *
from pk_architecture import PKObject
from pk_architecture import PKNode
from pk_architecture import PKCmCommunication, PKCmSequence, PKCmLeave
from build_gui import Build_gui
from MainWindow import MainWindow
#from MainWindow import guiThread

#from test import Ui_Form
from threading import Thread
import Tkinter, ImageTk, time
import thread
from Tkinter import *
import Image,ImageDraw
from PyQt4 import QtCore, QtGui
from cv2 import cv

import numpy,cv2
from PIL.ImageQt import ImageQt
from PyQt4.QtCore import QObject, pyqtSignal

global movetuple
global iptoset

class Gui(PKNode,QtCore.QObject):

# send = QtCore.pyqtSignal( str, name='send')
# temperatureRaisedSignal = QtCore.pyqtSignal()
# closed = QtCore.pyqtSignal()
def __init__(self, name=None, parent_node=None, **kwd):
# Define the ports
input_port = {'gui_in' : (None, 'append')}
output_port = {'gui_out' : (None,'replace')}

# Create the node
comp_mod = PKCmLeave(self)
PKNode.__init__(self, name=name, parent_node = parent_node,
input_port=input_port, output_port=output_port,
sync=True, threaded=True, period=1.0,
comp_mod=comp_mod, **kwd)
def init_handler(self, **kwd):


def compute_handler(self, input_data, output_data, act_cycle= -1, act_time=None, act_period=None, **kwd):
global movetuple,iptoset

#New code for displaying numpy array from camera
window = self.gui.window

def stop_handler(self, **kwd):

def reset_handler(self, **kwd):

#Thread for starting GUI
class guiThread(Thread,QtCore.QObject):

def __init__ (self):

self.window = None = None

# data=self.input_data['gui_in']

def run(self):
# Build up the Qt4 GUI
# global tempnumpy
print "shyam" = QtGui.QApplication(sys.argv)
self.window = MainWindow()

Main issue is i am using Qpixmap for displaying Numpy arrays on my gui widget but when do this in Gui class compute handler we get "not safe to use Qpixmap outside main thread" but when i run this part inside run inside thread i need the numpy arrays which is i gui class,,

Could u please help me in signal and slots method for passing input_data['gui_in'] value in to my gui thread as it contains feed from robot.


Umut   2012-01-29 01:06:51

Thank you very much for this nice tutorial.

Manoj Thorat   2012-01-27 09:03:55

nice job..

arhsa   2012-01-03 10:21:03

nice post
i try to learn QT ,
keep writting !
thanks a lot

Leslie Satenstein   2012-01-01 20:17:09

your tutorial along with a utube qt tutorial got me interested and I am continuing with yours because it is great.

I use vim and will be updating .vimrc and /share/vim... files in linux.

null   2011-12-19 13:20:39

nicely done!
thanks to you...:D

Ameet Kumar Maharana   2011-12-03 03:37:54

Can I get the link to download the entire tutorial in .pdf or some other formats. I don't have an internet connection at my home so want to keep the tutorials handy.

Ramesh   2011-11-28 07:56:55

Excellent one! Thanks for putting it together.

wayne   2011-11-24 03:52:08

I sincerely appreciate your effort. Your tutorial caused me to try once again attempt to understand QT. However, :-(

Besho   2011-10-31 04:36:34

just an update on my previous post..

I found a solution using popen and fgets...

thanks again for the tutorials...

Besho   2011-10-31 02:20:56

Thanks for the tutorial.. I would appreciate your help in the below...

What is the simplest way to have another simple c++ program to output to another QT form application?

application 'A': I have the source code for c++ that outputs X & Y (cout to terminal)
application 'B': I have another C++ application being build under QT and Netbeans that includes two lineEdit boxes and a label widget showing some result of the the lineEdits (say X + Y)

I need:

1. code to launch application 'A' from application 'B' as a separate application (not having to wait for it to finish). I would like to have this to work in both Linux and windows with option to start it in normal window, minimized or hidden.

2. add code to application 'A' to direct its output to fill the lineEdit boxes in application 'B' with the X & Y values (continuously and refreshing the result in the label box)
3. command to terminate application 'A' from application 'B' (again cross platform pls)

Many thanks,

NewOne   2011-10-25 14:08:09

Thank you sir.

Joseph   2011-10-20 12:49:27

Excellent tutorial, thank you.
I've modified the code a bit, but it gives me errors regarding the setupUi function.

First off, make couldn't find it if I didn't include QWidget...
Second, I get the error: no matching function for call to ‘DNAViewer::setupUi(DNAViewer* const)’, where DNAViewer is the name of my class instead of myqtapp, since I'm extending this code.

Any help would be appreciated!

ashken   2011-10-17 17:11:42

Nice tutorials!!
for the person asking on how to connect to MS-ACCESS database this is how to.

QSqlDatabase db; //this variable is better declared inside a class
db.setDatabaseName("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=mydatabase.mdb"); //mydatabase.mdb is the name or path to ur DB.
// handle error
dont forget to add
QT += sql
in your pro file

niks   2011-09-20 07:52:52

how to write & compile c code in qt?

M. Duvivier (Belgium)   2011-08-11 11:33:19

Thanks a lot for this tutorial! Excellent to get on-board and understand the principles of Qt very quickly .

José Juan   2011-08-06 20:00:05

Estoy tratando de instalar el Mysql para Qt pero tengo este error, me pueden ayudar por favor.
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Qt/4.7.3/src/plugins/sqldrivers/mysql'
mingw32-make[1]: Nothing to be done for `first'.
mingw32-make[1]: Leaving directory `C:/Qt/4.7.3/src/plugins/sqldrivers/mysql'

ronnie guntalidad   2011-07-30 15:32:44

if i have a time and if i can understand well i will try this one of the tutorial that you uploaded, thanks in advance,

Manuel   2011-07-23 22:18:58

Estoy desarrollando un aplaicacion en Qt

kinjal   2011-07-15 06:22:17

how to pass multiple strings as structure variable for Push button text

kinjal   2011-07-14 12:50:08

I had error like this.

":: error: collect2: ld returned 1 exit status"

what is meaning of that error in qt please u may had this kind of error occur before.
so tell me.

vipin   2011-07-12 11:08:50

help me

ekkehart   2011-07-11 08:46:14

Great tutorial! It was very helpful, and from my point of view certainly worth the effort! Thank you.

I have a further suggestion: A common task is to write a frontend for a command line program that is called through QProcess, fetches the output and processes this further. If you could add a button to your example that does that, this would be most useful to many.

The corresponding example provided by Qt refers to Qt 3. For Qt 4 they provide only code snippets which I don't get to work. As I see from the discussion on the Net, this is a common problem, and I am apparently not alone.

(I want to write a Qt frontend for an old statistics program of mine, written in C.)

Salumu   2011-07-11 04:12:21

Thanks for this valuable material!

shubham   2011-06-27 09:46:41

Thanks sir, you have made learning qt more easier........

Kevin   2011-06-12 11:09:16

Thanks for teaching me!

Ryan   2011-06-03 23:02:32

Thanks for the great tutorial. In just a day I was able to put together a GUI that uses QT sockets to communicating with an embedded system! This saved me a lot of time just trying to figure out where to start. Thanks!

Manuel   2011-05-15 21:11:39

Hi, sorry for this question, but: suppose you use 'qmake' to create an executable 'example'. That executable runs ok in my computer but only if under "home". If I copy the executable to a pen-drive, for example, or any other drive, or even another computer, it will not run, and ask to choose an application to run it... how can I make an executable that will run in any drive? Is it possible? Sorry, this must be really a question of a beginner, but... Thanks! :)

coolguy   2011-05-12 06:34:22

This is an excellent tutorial for beginners. I have one question. I have developed a small application on linux ubuntu. Now I want to run it on other systems windows/Mac/embedded device. What things I need to do to ensure that my application runs everywhere?

sankar   2011-04-28 18:25:48

i am very hungry for learning linux please give me knowledge about linux

XXX   2011-04-27 10:10:08

That's a very nice tutorial and helpful for me! Many thanks to you!

gulzar   2011-04-04 08:32:02

i have doubt in constructors
in c++ programming
suppose an example
show(int x,int y)
this wrong i know bcz in java
the same can be written as
show(int x, int y)
then in c++ what is used in place of "this" when we have both same name(actual and formal)

gousia begum   2011-04-04 08:28:32

i have doubt in constructors
in c++ programming
suppose an example
show(int x,int y)
this wrong i know bcz in java
the same can be written as
show(int x, int y)
then in c++ what is used in place of "this" when we have both same name(actual and formal)

Sushma   2011-04-02 18:10:24

Hello sir/Madam,
I have installed Qt has explained in above method and also i set environment variables. But when i execute qmake -v i am not getting qmake version. It is not detecting internal or external command. Below i have pasted command prompt output. Verify and Please inform me how to set qmake.

C:\Documents and Settings\Navya>gcc -v
Reading specs from C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/specs
Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --host=
mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable
-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shared --e
nable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --enable-ja
va-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchroniz
ation --enable-libstdcxx-debug
Thread model: win32
gcc version 3.4.2 (mingw-special)

C:\Documents and Settings\Navya>make -v
GNU Make 3.80
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A

C:\Documents and Settings\Navya>qmake -v
'qmake' is not recognized as an internal or external command,
operable program or batch file.

Albert Ruman   2011-03-28 13:58:16

Hi, I'm working in fedora Linux core, programing in Fortran and Linux shell. I have made many programs but now is wise that them link in one application window.
Thanks in advance.

manuel   2011-03-18 20:17:11


Petter Ivarsson   2011-03-11 16:04:21

What a nice tutorial! Perfect for me when I am now entering a new world with QT and C++.

joseph9560   2011-03-01 09:43:23

Great tutorial. I spinned around documentation, training materials and all and learned something. I can only wish that I learned those things from this tutorial. It is super cool. I learned few things from other materials in past few months but I still missed some thing that is in the tutorial. Thanks a lot. But if author have some time then he should update the tutorial for newer version of qt creators. But one can still learn from this tutorial.

jimm   2011-02-09 13:15:43

nice tutorials and good to see some wtc (911truth) info on your site

Lorenz Polster   2011-02-01 20:59:58

It seems to me that this is an excellent tutorial: the right speed: details and overview balanced. well-done interweaving of skeleton and example. a well selected line of steps. i have the vague idea of making a gui to remind. Thank you very much.

mahe   2011-01-29 05:25:35

can any1 giv me the syntax for database connectivity to MS-Access in QTcreator??

maheshwari   2011-01-29 05:21:40

can anyone give me the syntax for comparison of two strings using if statement in qt creator??

lee hai   2011-01-28 04:59:44

I've experienced in c++ programming, but almost in window with vc++. Now, I want to developing a small program that using socket to tranform data bettween client and server then update into database. Moreover,it must running on many difference platforms. So that, I've started to study programming in qt. This tutorial is really helpful for me. Thks author

Michael   2011-01-18 19:31:14

You need to have someone proofread your web pages.

Al   2011-01-15 12:17:35

Installing any librarys on ubuntu should be strait forward. All you need to do is open up synaptic and search for "Qt4", the latest stable version should be in there.

Prabhakar    2011-01-13 17:47:54

Can you tell me how to install qt4 libraries on ubuntu-10.04.

Thank you.

setu   2011-01-09 14:02:45

hi there!!! wanted to know some good book on this....

Seb   2011-01-07 00:04:04

This is what I was looking for! A very good beginners tutorial!

hiwatari   2011-01-03 06:32:59

this tutorial is awesome.. keep it up..

charles richard shultz jr   2010-12-06 13:43:52


I agree that there are none/very few tutorials on QT development for the real beginner. I would like to learn QT along with C++ to develop a very small beginner level CAD program that I could/will develop under GPL. I have a long history with computers but nothing with C++ programming.
I can see that your first language is not american english which is true for your "proofreader" as well. All the words seem to be spelled correctly but the grammar is a little off every few sentences. It doesn't seem to flow smoothly. I am offering to help but I would like to go through your tutorial first as a student to hopefully get started in the development of my project.

Contact me at any time at the email address I entered above or if this system didn't keep track of it properly "". I hope the spam bots don't get my email address from this. My development environment is Debian/Gnome/KDE AMD64 and latest QT and GNU C++ compiler as of December 6, 2010.

Just trying to learn QT, don't care about the other stuff.

thank you for your effort,

bonch   2010-12-04 21:27:58

The 9/11 analysis is total garbage for kooks. It's been debunked so many times by countless experts, including the engineers who built the towers in the first place.

markuz   2010-11-26 15:59:40

You should made a downloadable PDF or something like that.

zzz   2010-11-22 02:50:54

still too complicated for beginners

Peranimo   2010-10-17 18:45:27

In my case there is environment settings bat file :

Troy   2010-10-10 00:38:13

Thankyou very much for your tutorial. I had no idea about Environment Variables to get qmake and make working. I am using Windows 7 x64 Professional and it is working perfectly. Also because of the Qt install file structure i had to use C:\Qt\2010.05\qt\bin and C:\Qt\2010.05\qt

nagasai   2010-10-06 13:12:27


Thanks a lot.
It helped me to understand QT in simple way.


nishith   2010-10-04 11:23:06

Have a very basic doubt in QThread,
In your tutorial in the Run function you had placed your code something like
//heavy operation

my confusion is what is the use of exec... as everyone will say it is to start the event loop. But whats the use of starting the event loop after performing the heavy task. ie suppose in the heavy operation there is a synchronous function which takes about 10 sec to complete but since exec is started after the execution of the operation is over what is the benefit of having that. we mainly need exec to stop the running thread.


john G   2010-09-26 01:33:50


I can actually understand this.
Really good work.

Thank you

abhishek   2010-08-23 10:51:56

How to connect an user defined lib to a programme..

asish   2010-08-10 10:54:24

this is great tutorial ....

thank u very much


cochise   2010-08-01 16:26:49

The tutorial is realy exelent and very easy to understand and learn.
Can I translate it for brazilian porttuguese?

Ajisebutu Ayoyemi   2010-06-11 23:12:14

This is a good summary to the book "C++ GUI programming with Qt4", i really like it, thanks a million.

--Share the truth of 9/11.

kamyow   2010-06-01 09:25:34

dist. packages usually have <u>onle</u> "release" QT version which is not suitable for debugging). I'll <u>how</u> few tips on compiling QT from sources.

-the truth of 911-

Rafa;   2010-05-23 01:16:51

Finally I found what I've been lookin for. Great tutorial and great website about 9/11 truth-guys, you're not alone, there's milions of people who know the truth and nobody can hide it!

piyawan   2010-05-11 21:07:29

the best~~~~~

^____^ thank you~~~~

Conrado Camacho   2010-05-10 15:31:40

Excelent Manual. Even better than the official one.
Excelent and clear explanation

¡I finally understood the structure of a QT Program!

My best regards

dkm   2010-05-08 17:48:32

It's what I'm searching for and fully worth the efford! Thank's.

Adewale Sodangi   2010-05-06 08:25:18

need to understudy the tutoial

jinjing   2010-04-29 09:29:57

hello,I am using QT.

dav   2010-04-25 21:04:19

thanks for this. I haven't started it yet but will today. I'm downloading qt4 creator and some other related items now.

Jess Portnoy   2010-04-06 00:43:43


Very nice work and most certainly worth maintaining :)

Here are some notes:
0. In "My first Qt GUI application" [], you wrote:
"We use Label, Combo Box, Text Edit, Spin Box, Check Box. Drag and drop appropriate widget from left menu to our form. We name (objectName) Browse button "pushButton_browse", Do something button "pushButton_do"... We'll need object names later when connecting with functions (slots)."

You should probably mention the first input widgit is QLineEdit [Line Edit] and not QTextEdit.
Since in a screen shot the two look exactly alike it can get confusing as some methods and slots exist for one but not the other, also, naturally, default objectName will be different for the two so if a person were to use QTextEdit for the first widgit, it will not work :)

1. In "Customing widgets (subclassing)" []
Broken URL:
"My first Qt GUI application" points to HREF:, should be:

Keep up the good work :)

sudhanshu   2010-03-30 20:13:51

please help me in downloading the qt tutorials..

Ruslan    2010-03-24 15:26:21

Thank you very much for helping people.Actually i am from Kazakhstan but i think the people like you is very to its country

phil   2010-03-14 03:26:36

I want to have a separator (QAction for which isSeparator() returns true) in a menu, with text displayed in the separator, as is pictured (the "Alignment" separator) in the menu at

I call the setText() method of the separator, but the text does not show up.

The QAction reference page,

says: "How a separator is represented depends on the widget it is inserted into. Under most circumstances the text, submenu, and icon will be ignored for separator actions." But it says nothing about how to tweak the circumstances.

I assume it's possible, because besides it being pictured, there's a snippet of code at

that seems to be trying to do this very thing, to wit:


But when I download/build the source for the menu example, the "Alignment" text was not showing up. Tried it on my Windows 7 box with Qt4.6.2, and on a Linux machine with Qt4.5.2 (after commenting out line using a QKeySequence that wasn't defined back then).

I spent rather a lot of time looking for something in the QMenu, QAction, and QStyle reference pages (all 4.6) that would make separator text show up. Didn't find anything. Is it possible? How?


santi   2010-03-09 06:05:51

I m working in Indian IT and eGovt. department(NIC) and current developing database application which is cross platform independence.. I like qt programming so much....

Chris   2010-03-06 15:32:30

hi, I'm just getting started with QT, coming from MSVS. I'm tasked with a project that will include dockable windows. I looked at the sample app provided with the SDK but if doesn't go far enough to explain how you would go about designing dockable dialogs in the designer and then implementing them into the Creator. The dialogs I'm creating are rather complex and thus creating them by code alone could prove lengthy. The whole thing just has clicked for me yet. How about a quick tutorial on building dockable dialogs in designer and implementing them in creator?

Chris Lane
Slick Systems Development

Rimkashox   2010-02-28 13:40:35

Amazing tutorial man, the best beginner tutorial for QT on the whole net! Keep the good stuff coming.

hakermania   2010-02-07 14:56:45

Very helpful.Thx

Mu   2010-01-27 11:14:28

I just finished the first GUI app tutorial. Thanks for making it so easy.

One thing I had to do is put the paths to qmake.exe and make.exe in Windows System Environment variable, because otherwise Windows can't find qmake and make from the command line (without typing full path).

Muthusaravnan   2010-01-20 06:09:23

it`s nice tutorial to all begineers ...
i want ask one douubt in qt creator.....
my question is what is the header file using to perform the FILE operations like fopen fclose and create a file pointers ......
please clarify my doubts ..........
thank u ........

chnandra naik   2010-01-11 10:22:16

Thanks! This ir really awsome! Finally I´m able to perform a simple interface in c++!
However, the code to center the GUI window is not working in my program.
Possibly I´m not pasting the code in the right place. I´m placing it after this block of code, inside the braces:

setupUi(this); // this sets up GUI

// signals/slots mechanism in action
connect( pushButton_browse, SIGNAL( clicked() ), this, SLOT( getPath() ) );
connect( pushButton_do, SIGNAL( clicked() ), this, SLOT( doSomething() ) );
connect( pushButton_clear, SIGNAL( clicked() ), this, SLOT( clear() ) );
connect( pushButton_about, SIGNAL( clicked() ), this, SLOT( about() ) );

I´m placing the block of code here!!

eric stockman   2009-12-22 11:40:00

Dear ;
Thanks for this tutorial .
I succeeded in developing my first Qt windows-program thanks to this guide.
What I am missing though are tips and Howto's to develop programs in an Linux_Ubuntu environment , an environment I prefer above .

Eric Stockman

ashish   2009-12-18 16:48:59

I appreciate your effort to disseminate your knowledge about Qt, it is worth and provides a good start for beginners.
Thanks alot!

Eduardo Domingos   2009-11-27 16:45:11

Hi again!
I´ve already solved my problem. I restarted msvc and now it´s performing the code!
Thanks anyway,


Eduardo Domingos   2009-11-27 14:36:43

Thanks! This ir really awsome! Finally I´m able to perform a simple interface in c++!
However, the code to center the GUI window is not working in my program.
Possibly I´m not pasting the code in the right place. I´m placing it after this block of code, inside the braces:

setupUi(this); // this sets up GUI

// signals/slots mechanism in action
connect( pushButton_browse, SIGNAL( clicked() ), this, SLOT( getPath() ) );
connect( pushButton_do, SIGNAL( clicked() ), this, SLOT( doSomething() ) );
connect( pushButton_clear, SIGNAL( clicked() ), this, SLOT( clear() ) );
connect( pushButton_about, SIGNAL( clicked() ), this, SLOT( about() ) );

I´m placing the block of code here!!

What I´m doing wrong?

Best Regards


thetrojan01   2009-10-28 22:42:03

Many thanks! You've helped me a LOT! =D

Hamad   2009-10-27 21:58:29

Many thanks, and please keep it up. The tutorials are very helpful.
Im looking forward to see a master details database application with lookup table, I will be really thankful

Michael berger   2009-10-14 14:32:25

I am a Linux enthusiast using openSUSE 11.1 and I love it!
Knowing about QT4's features and powers or even using them is of great interest for me.
However, I found it very hard to begin with it (although having gained some experience with Visual basic).
Will start another attempt using your Tutorial and then revert.
Thanks a lot!
Michael Berger (dedicated Linux user)

Nishant   2009-10-06 21:05:16

I ama newbie with qt. Just installed qt and as pe the instructions i did set the env. variables for qt 2009.04.Now in the qt command prompt;only gcc -v gives the desired output as per the tutorial but nothing else.someone please rectify my mistake , i have tried a lot of forums and all stuff.

sonia   2009-09-09 08:32:51

how can I use App.EXEName in vb to QT4?

parisa   2009-09-09 08:32:40

how can i use Err.Number from vb to Qt C++?

Kenny   2009-08-16 17:24:54


The IDE to be used for development would be KDevelop. Along with that the basic build tools need to be installed.

The following tools need to be installed.
gcc   (The GNU C Compiler)
g++ (The GNU C++ Compiler)
gdb  (The GNU C\C++ Debugger)
kdbg  (Front end to the gdb debugger)
make (GNU make utility to maintain a group of programs)
qdevelop (Multi platform IDE for programming with QT4)
kdevelop (IDE for programming in KDE)
qt4-designer (Graphical front end tool creator for QT4)
qt4-dev-tools (Cross platform Makefile generator for QT4 along with development tools, libraries and headers)
qt4-doc (Documentation for QT4. After installation you can bookmark "/usr/share/doc/qt4-doc/html/index.html" by opening it in browser.
kdiff3 (GNU GUI diff tool)
These packages can be installed using either "Synaptic Package Manager" or "apt-get" from command prompt.


PS - Thank you for spreading 9/11 awareness, despite the masses continuing to sleep

Rajeshsan   2009-08-13 13:04:01

Hi.... Im using ARM 11 Phytec board for development i want to install Qt on Board. I tried with 4.5.2 bcox 4.5.1 was not available on net to download.. plz let me know how to install Qt on ARM 11 Board. I want to know which Qt version is installable on ARM BOArd PHYTEC PRODUCT... I want to install on my board test sample programs how it runs on board to develop my own GUI for our project.
Thanks in Advance

wssdc   2009-08-03 05:23:08

Two minor errors:
In dnd.html, source code listing for mylineedit.cpp, less/greater than symbols display as ampersand lt/gt. They're ok in other places.

In threads.html, the link to "My first Qt GUI application" is broken.

OrdizR   2009-06-25 10:10:03

I have nothing but praises. I was turned off on learning QT due to lack of beginner (this kind) materials. Looks like I am going to be hooked back. Appreciate you efforts. I do self studies and would like to request copy of your material that I could take with me and use in areas where internet is not available.

Showket   2009-06-18 10:06:54

How can i get Qt Software

sector   2009-06-03 22:36:58

JAMSHEED - have a look QProcess class.

JAMSHEED   2009-06-03 06:52:59

How to call linux user commands(eg FIND and CAT) in qt4

Phil   2009-05-29 00:07:11

Thanks for the tutorial. Very helpful. Keep up the good work but do get rid of that stupid 911 conspiracy theory stuff.

Saurabh Saini   2009-05-23 00:22:10

i have configured QT for my VC++ using this PDF " " and it provides me a simple example to run but i m getting error messages:-

1>------ Build started: Project: qttest2, Configuration: Debug Win32 ------
1>Performing Makefile project actions
1>mingw32-make -f Makefile.Debug
1>mingw32-make[1]: Entering directory `f:/CRAP/qttest2/qttest2'
1>mingw32-make[1]: Leaving directory `f:/CRAP/qttest2/qttest2'
1>Makefile.Debug:58: *** missing separator. Stop.
1>mingw32-make: *** [debug] Error 2
1>Project : error PRJ0002 : Error result 2 returned from 'C:\WINDOWS\system32\cmd.exe'.
1>Build log was saved at "file://f:\CRAP\qttest2\qttest2\Debug\BuildLog.htm"
1>qttest2 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

plz any one can help me
- saurabh

Guenther Schardinger   2009-05-05 17:45:51

I like this tutorial.

Shibu.T   2009-05-04 07:28:13

Hello, I like this tutorial very much this tutorial is absolutely great for beginers!
can you just give the tutorial in pdf format
Thanx in advance

Divahar   2009-05-01 15:41:28

Great step by step tutorials :)

You have started from very basic things and the approach too is well structured.

and.. it was helpful to me a lot and lot...

Best wishes

Milos   2009-04-07 21:43:30

First of all I don't understand why C++ source file can not be compiled. Only QT Project can. Second, the certain libraries are (probably) not linked statically, because I get a message "The application failed to start because the mingwm10.dll was not found". Any ideas?

Zeke   2009-03-28 04:30:44

Can you please remove that World Trade Centre thing. I'm tired of seeing it. It happened 8 years ago. Please remove it

hugo   2009-03-25 00:52:54

Very good tutorial. Congratulations!

tiago   2009-03-17 15:22:44

Thank you for this useful tutorial.

sss   2009-03-12 11:00:58

hai newer of linux,its tutorial for beginners..but i am asking one question..i am confuse for coding.because,where u write code for new application developing in qt4.ur saying any text editor but i am do it..but not clearly tell me..coding process..generally qt3.3 its generates directly main.cpp file and all...i am confuse how to in qt4 .pls give me replay as early

Archie   2009-03-05 18:43:27

The thread section is helpful, but I still have a question about making it communicate with the main window.

For example, instead of using qDebug() for the output, could you send the information to a QTextEdit in the main window while still having the GUI be usable? How would something like this be accomplished? I ask, as I have written a large text file parser and while it might take 3 minutes or more to parse a large file, my GUI is unusable. I'd like to be able to parse multiple files at once and have the individual threads update the main window QProgressBars. Any help would be appreciated.

This is a great tutorial! Thank you very much for your effort!


Boechat   2009-03-03 22:11:39

Thank you!
Great Tutorial!

Firewolf   2009-03-02 22:07:33


Great job! Masterpiece for beginners!

Pat   2009-02-26 12:16:36

Thanks for the great tutorial.

Your effort is very much appreciated!

It is really needed too, as a search for "QT4 C++ tutorial" seems to bring up only around 5 or 6 good results in Google.

Keep up the good work and I will probably be back often for reference as I have just started programming with Qt recently.

BTW, QDevelop, Monkey Studio, and Code::Blocks are all working fine for me in Ubuntu Intrepid Ibex. Code::Blocks works fine in Windows XP as well.

Tristan   2009-02-13 10:31:59

I think you should include things you feel strongly about on pages you create....ON TOPIC, I will be trying to create a cross platform IN CAR GUI (infotainment)App using a combination of C and Python, This looks like it may be just the job....Many Thanks.
If the project is succesfull it will be sent to ubuntu repository.

Ernst   2009-02-05 21:05:32

There's a new IDE directly from Qt Software (still in beta):

lostson   2009-02-02 13:20:03

great explanations of basic features and function this helped alot, thanks,

jayhawk   2009-01-23 15:57:32

i found the concept of SLOTs very hard to understand.
First i tried to make an app in only one file (main.cpp)
that made the SLOTs invisible. But this works:
the following three files is a very simple example of
how to make your own SLOTs using QT4.
put the three following files to a directory of
their own. then in a terminal type:

qmake -project

now run your program: if the directory youre in is
/<some path>/test
then type: ./test
to run the program. click the button and see the text

//this is mainform.h
#ifndef _MAINFORM_H_
#define _MAINFORM_H_
#include <QWidget>
#include <QPushButton>

class cMainWindow : public QWidget
cMainWindow(QWidget *parent = 0);
public slots:
void theButtonClicked();
QPushButton *theButton;
//end of mainform.h

//this is mainform.cpp
#include "mainform.h"
#include <QMessageBox>

cMainWindow::cMainWindow(QWidget *parent) : QWidget(parent)
setFixedSize(160, 90);
theButton = new QPushButton("click me", this);
theButton->setGeometry(10, 10, 140, 70);
connect(theButton, SIGNAL(clicked()), this, SLOT(theButtonClicked()));

void cMainWindow::theButtonClicked()
theButton->setText("you clicked me");
//end of mainform.cpp

//this is main.cpp
#include "mainform.h"
#include <QApplication>

int main(int argc, char *argv[])
QApplication app(argc, argv);
cMainWindow mainWindow;;
return app.exec();
//end of main.cpp


best regards /jayhawk

ps: only our grandchildren will eventually get to know what really happend 20011109 !!!
:(i found the concept of SLOTs very hard to understand.

G   2009-01-16 19:16:03

" The reason why I decided to write this tutorial is that there is real lack of Qt tutorials for real beginners, people who want to start with Qt4 but they just don't know how. Qt documentation is really nice written, however it is hard to understand for average programmer. Examples bundled with Qt distribution are impressive but most of them are very difficult for beginner to learn from. "

Thank you very much man. This is Exactly what is needed!

Danang Suharno   2009-01-15 11:50:38

Very nice and comprehensive tutorial. May all living being be happy

Robert Cao   2009-01-15 04:55:00

It is good for "This tutorial is intended to be more practical than theoretical", better for download with some source codes to practice.

Nagadurgarao   2009-01-02 14:21:24

Hi sector, this site helped me alot to understand the basics of QT4 :)

aliasgar   2008-11-23 08:17:26


this is a great tutorial. I really liked it.
Further I am having a problem with installing the Qt on my machine. I have VS 2005 and am using the qt 4.4.1 commercial pack along with the VS integration pack. But some how there is a problem, when ever I try to compile, there is no .exe file developed and I get the message of variables not set properly. I have changed the option on the VS and given the qt 4.4.1 as the version. I also made the changes in the system variable by adding the QTDIR and adding Qt in the path variable. But still no use.
Can you guide me in this.


Ed   2008-11-13 23:07:55


I've installed QDevelop on Ubuntu 8.10, but am struggling to get anything working. If I create a new (blank) project, then select to add a new source file, I get the error message "unable to create file". I've tried several variations, and also creating other project templates (such as application with dialog) but always get the same error when I try to create new source files myself. Any ideas gratefully received.



Mohan   2008-11-07 07:58:22


This is a great tutorial for beginners.

I would like to know if we can call an other Dialog while we are on an another dialog box..using the designer.

I am new to qt!!!!!!!!!!!


marc   2008-11-02 22:52:18

hi got the token thing fixed but now im having trouble with lineEdit being undeclared, any ideas??

marc   2008-11-01 07:15:44

hi there,
In file included from main.cpp:3:
myqtapp.h:8: error: expected class-name before '{' token

ive tried all kinds of things but nothing works im new to this so if anyone can help?

akhil   2008-10-19 13:54:14

It is very good beginning so far.
Will send more comments after going through the rest of it.
Choice of 911 is an excellent idea, as it connects an abstract thing like programming
with a concrete attention catching event.

Ken N9VV   2008-09-28 15:13:54

Thank you Sector for such a wonderful Qt class.
Please create a book or pdf that we can purchase
from you! you deserve to earn some $$ for your
fine information.
thank you,
Ken - USA

corsair   2008-09-27 21:46:20

hi! great tutorial. it would be nice if one could download the whole tutorial as a zip archive or a pdf or similar. bafta!

Martin   2008-09-26 18:09:27

Great job, i learned basics of QT4 well, thank you for nice tutorial.

chandrasekar   2008-09-12 09:13:46

great tutorial and i learn a lot with it...

sector   2008-09-04 00:15:51

I'm glad you like it. I currently do not work with Qt very much but I'm happy that people find this piece useful.

qt learner   2008-09-03 23:50:14

I just want to tell you that this is the most informative and helpful qt tutorial I've ever seen. Thanks a million.

sector   2008-09-03 21:05:38

QwebView is not in 4.1,
but it is in 4.4,

yalin   2008-09-03 20:54:53

have you use qwebview before.? I have add QwebView, I compile, I got error.
I use windows xp system
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Yalin/test/Qt4'
C:\Qt\4.1.1\bin\uic.exe cibGui.ui -o ui_cibGui.h
I"C:/Qt/4.1.1/mkspecs/win32-g++" -o debug\cibGui.o cibGui.cpp
In file included from cibGui.h:4,
from cibGui.cpp:2:
ui_cibGui.h:16:29: QtWebKit/QWebView: No such file or directory
In file included from cibGui.h:4,
from cibGui.cpp:2:
ui_cibGui.h:41: error: ISO C++ forbids declaration of `QWebView' with no type
ui_cibGui.h:41: error: expected `;' before '*' token
ui_cibGui.h: In member function `void Ui_cibGuiForm::setupUi(QWidget*)':
ui_cibGui.h:135: error: `webView' undeclared (first use this function)
ui_cibGui.h:135: error: (Each undeclared identifier is reported only once for each function it appears in.)
ui_cibGui.h:135: error: `QWebView' has not been declared
In file included from cibGui.cpp:2:
cibGui.h:23:7: warning: no newline at end of file
cibGui.cpp:51:2: warning: no newline at end of file
mingw32-make[1]: *** [debug\cibGui.o] Error 1
mingw32-make: *** [debug] Error 2

sector   2008-09-02 22:54:56


strange, never seen error like this. I currently have qt 4.4.0 Win, self installing package from Trolltech and my_first_qt_app compiles with no problem. Try latest qt, I have no idea why this error pops up.

yalin   2008-09-02 22:23:14


I try to build a test project following your tutorial. I got a error.
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Yalin/test/Q4'
g++ -c -g -g -frtti -fexceptions -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB
tGui" -I"C:/Qt/4.1.1/include" -I"C:/Qt/4.1.1/include/ActiveQt" -I"debug" -I"." -I"C:/Qt/4.1.1/mkspecs/win32-
cibGui.cpp: In constructor `cibGui::cibGui(QWidget*)':
cibGui.cpp:8: error: no matching function for call to `cibGui::setupUi(cibGui* const)'
ui_cib_Qt4.h:47: note: candidates are: void Ui_CibWindow::setupUi(QMainWindow*)
mingw32-make[1]: *** [debug\cibGui.o] Error 1
mingw32-make[1]: Leaving directory `C:/Yalin/test/Q4'
mingw32-make: *** [debug] Error 2

sharms   2008-08-19 21:48:22

Thank you very much for the tutorial!

sector   2008-08-19 00:32:06

Hello all,

thanks for all comments.

No problem with using tutorial in teaching, all I ask is to put there URL somewhere, where it did come from. There is no printer friendly version but I think it can be printed directly from web and result will be quite OK.

Cheers all.

Ron McCarty   2008-08-08 16:59:50

I am interested in using your tutorial in a class I am teaching. Is that ok, and is there a printer friendly version of it?

Gaurav   2008-08-08 06:04:04

Hello sir, Great Tutorial i must say, Really

vinod   2008-07-29 08:02:25

Very useful. Thanks.

erik   2008-07-18 21:08:36

Great tutorial, thanks a thousand times!

Pheonix   2008-07-05 23:28:13

Thank you for writing the "My First Qt GUI Application" tutorial. It was very helpful in getting a grasp on what QT is all about. I have some programming experience, but this was my first time working with GUIs.

stanley   2008-06-23 09:25:26

what is the code??


stanley   2008-06-23 09:24:08

how to open another page from the main window???

PauloZ   2008-06-13 20:50:10

Hey this is avery good material!!! Thanx

santu   2008-06-10 19:15:18

The make command leads to the error below

C:\MinGW\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot fin
d -lQtGuid4
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\menus.exe] Error 1
mingw32-make[1]: Leaving directory `C:/Qt/4.1.4/examples/mainwindows/menus'
mingw32-make: *** [debug-all] Error 2

Aroni   2008-05-11 17:28:45

Now i get this error:

In file included from main.cpp:2:
myqtapp.h:8: error: expected class-name before '{' token
In file included from main.cpp:2:
myqtapp.h:23:7: warning: no newline at end of file
main.cpp:11:2: warning: no newline at end of file
mingw32-make[1]: *** [release/main.o] Error 1
mingw32-make[1]: Leaving directory `C:/c++/Qt/me-design'
mingw32-make: *** [release] Error 2

Aroni   2008-05-11 11:48:39

It doesn't work for me...make shows this error:

myqtapp.h:4:24: ui_myqtapp.h: No such file or directory
In file included from main.cpp:3:
myqtapp.h:7: error: `Ui' has not been declared
myqtapp.h:8: error: expected class-name before '{' token
myqtapp.h:8: error: invalid use of undefined type `struct QWidget'
../../../Qt/4.4.0/include/QtCore/../../src/corelib/kernel/qobject.h:71: error: f
orward declaration of `struct QWidget'
main.cpp: In function `int qMain(int, char**)':
main.cpp:10: error: 'class myQtApp' has no member named 'show'
mingw32-make[1]: *** [release/main.o] Error 1
mingw32-make[1]: Leaving directory `C:/c++/Qt/design'
mingw32-make: *** [release] Error

Mmohammed   2008-04-28 17:16:07

So thanks

311797900   2008-04-28 03:43:29

hi!I'm very interested in this section.

sector   2008-04-26 22:27:58

to James Redin:

Hi, just locate that dll (ie. in your C:\Prog.. Files\MinGW) and copy to directory where your program executable is on other machine, it will be ok then.

James Redin   2008-04-26 20:09:18

I'm developing a calculator application under QT 4.1.1. Found that the executable program only runs in the Windows PC I used to compile the program.

When I try to run in another PC it complains that the the mingwm10.dll is missing.

Can you give me some advice?

James Redin

Faryshta   2008-04-25 06:57:55

Dude i didnt understand how to compile, it is suppose to use uic to make .h file not copy paste from a tutorial every time i need something.

Neither says how to use the implementation to create the c++ file.

Remember absolute beginner.

windylu   2008-04-09 10:29:32

Nice, Thanks very much. this is a very good tutorial for beginner. It solved many problems I've met. Really appreciate:)

L.G.   2008-04-03 11:25:32


Karl   2008-04-01 10:35:05

Cool tutorial dude! Just what I was looking for.

Uncovering 911 is the starting point and the key to freeing humanity from blind submission to religion and taking authority as truth. Watch 'Esoteric Agenda' and 'Zietgiest'.

A.R.   2008-03-24 18:38:25

Thank you for the tutorial, I really wanted to learn how to use the code that is generated by the UIC and this tutorial did just that. Thanks again. :)

sudanix   2008-02-26 17:27:53

Good tutorial,,


CrAZzY   2008-02-25 23:44:00

this tut sucked!, first that motherfucking make of qt never completed (several days)
second, when i saw on page 2 that you want me to do it the motherfucking graphical way. NO DAMN WAY!!, i want to learn how to CODE!!!

Jo.Ander   2008-01-26 03:18:51

Thank you for such a tutorial that's easy to understand (relatively).

I had a few bugs on the way, had to change my uic and qmake links to uic-qt4 and qmake-qt4, that made things better. (that honestly did take me a while to figure out >.<)

Though I think that helps to understand better

this is a really good step towards Qt-literacy. (at least it seems to me, this is the first time I've opened a window in C++ w/ an X11 environment. I'm more familiar with Java, and have been spoiled by Swing. :P .Thanks again

p.s. Ok, so the author had a few small links to his 9/11 page. so? I think putting up with a small green box is more than a good deal for a tutorial...

bright   2008-01-10 23:05:09

Please, keep your politics separate from your computer help. A simple link to your site about 9-11 will do.

> Please do not advice me what to do.

diego   2008-01-02 07:27:19

Excellent material!

Thank you!

avk   2008-01-01 17:06:44

brilliant tutorial!!!

thanks a ton

sudheer   2007-11-21 12:08:06

Hi friend its really a nice tutorial for the biginners, but(My first Qt GUI application)
is not comipiling in linux(Qt4.3.2) and it giving error as below, any suggesions.....

[sudheer@localhost filebrowser6]$ qmake
[sudheer@localhost filebrowser6]$ qmake
[sudheer@localhost filebrowser6]$ make
g++ -c -pipe -Wall -W -O2 -g -pipe -m32 -march=i386 -mtune=pentium4 -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -I/usr/lib/qt-3.3/mkspecs/default -I. -I/usr/lib/qt-3.3/include -I.ui/ -I. -I.moc/ -o .obj/main.o main.cpp
In file included from main.cpp:2:
files.h:9: error: `Ui' has not been declared
files.h:10: error: expected class-name before '{' token
make: *** [.obj/main.o] Error 1

chetan   2007-11-15 22:57:22

Brilliant tut, just awesome... please Keep on writing even better tuts... good luck!!!

Mar   2007-11-08 23:14:45

Good work! I'm using qt-4.3.1 with mingw 3.4.5 You need to make one modification in myqtapp.h, Ui::myQtAppDLG become Ui::myQtApp, according ui_myqtapp.h

Dimi   2007-11-05 00:53:53

Very helpfull.
Good work.

shweta   2007-09-20 10:48:55

I m using QT 4.1.1 and facing many problems like
1.How to submit the string from TextBoxes into the database.
2.IDE available or notepad is only code Editor

smokxx   2007-08-31 20:38:23

Great job. And thx for information about 911 they're very interesting.

Erice internet    2007-08-26 19:38:03

Could we avoid to read 911 crap every two pages on the intrnet ?
I don't think it's more ridiculous than discussion about the sex of angels of the middle ages... So feel free to spend your time as you want
But, please Could you please keep it in a separate page.

dok   2007-08-24 10:12:12


Your tutorial is very helpful. Good examples and links.

mito   2007-08-05 22:53:27

Compiled "My first Qt GUI application" with qt 4.3.0 without a problem.

fullmetalcoder   2007-07-25 11:11:49

Just mentioning that you forgot a few links :
* Edyuk (IDE for Qt 4) :
* Cobras (yet another IDE for Qt 4) :
* QtNode (wiki and IRC channel) :
* (french "equivalent" of QtCentre : forum, wiki, news, ...) :

there are probably even more but these are by far the most useful IMO.

md   2007-07-16 04:09:37

Ok, Here is an EASY thing to miss under Linux: 1) Run qmake -project to generate project 2) Run qmake AGAIN to generate Makefile 3) Now run make to compile application.

Failing one of these step will give you the "undefined reference to vtable" kiss of death.

Also, the setupUi(this) requires a QMainWindow*, so either Qt Designer can cast it to a QWidget Class or you must labor to make your mainwindow derive directly from QMainWindow instead of QWidget as show in the examples.

Typecasting causes segfault. setupUi( (QMainWindow*) this) ; ---> segfault!

Nice Tutorial. Now I need to have a integrated IDE so I don't waste time with gdb commands. Have gotten spoiled on syntax highlighting while in debugger.



sector   2007-06-29 13:06:09


I have unfortunately never used Qtopia, so I'm unable to give any links/recommendations about it.

Durgesh   2007-06-29 12:46:37

I found your tutorial very nice but its not for what i needed(its for desktop application ),I m very new be to the Qtopia and want to develop the application for embedded system means a application which run on Mototrola hand set which have Linux OS.I downloaded the Open source Qtopia 4.2.2 and build it and I m using the fedora core 7 linux.Also read the doc comes with it but not understand from where to start.So i want the information regarding how do i start working with Qtopia4.2.2 and Qt4 to design the embedded application.Do u have any link for ,Tutorial like yours which show me how to start with hello word application and have some nice example to develop the application for the embedded system using qtopia and even have how to configure the Qutopia for embedded devices ,I could not understand the docs come with Qtopia and their flow.


Cornelius   2007-06-21 15:59:21

Qt 4.2.3 Runtime Installer for windows:

sector   2007-05-31 10:25:56


This is how it's possible to list all DLLs needed to run qtapp under Windows. You can use same trick in linux.

F:\qt\my_first_qt_app\release>objdump -p myqtapp.exe | grep DLL
vma: Hint Time Forward DLL First
DLL Name: KERNEL32.dll
DLL Name: mingwm10.dll
DLL Name: msvcrt.dll
DLL Name: QtCore4.dll
DLL Name: QtGui4.dll

On windows you need these files: mingwm10.dll QtCore4.dll QtGui4.dll

On linux I think you will need these .so files:

Be sure to make release binary -> "make release", not debug. Run app from console (./myqtapp) to see error messages. Placing binary and libraries in the same directory should work. If not, place libs to /usr/lib or /usr/local/lib.

Jessica   2007-05-29 04:16:03

Hello sector,
Sincerely thank you, I will try these solution, could I ask how to copy all files needed to run my app with my binary? Only place my binary and library needed in the same directory? I am interested in the (2) item. Thank you ^_^

sector   2007-05-27 22:28:01

Roberto: thanks


Sorry, I forgot about this forum for a while.

You have to:
1) compile Qt4 distibution on your B linux machine
2) copy all files needed to run your app (like with your binary (I'm not sure if this really works on linux, but on windows it does)
3) build static binary (all that .so are packed into single binary file, you have to specify that what you are compiling Qt4)

Roberto   2007-05-17 23:25:07

Great!!! I have learned How to programming using Qt4 reading your tutorial.
A very nice tutorial for beginners.
Good Work!!!

Jessica   2007-05-11 09:39:42

I have compiled successfully a file with Qt4.2 in A machine of linux but I copy that file to B machine of linux that is installed Qt3.1, It can not work and show message "error while loading shared". I don't know what happend. Could you help me, please? Are there any suggestion? Thank you..

sector   2007-05-03 21:04:18


I'm rather busy right now, maybe I will later. You can have a look at this QMainWindow example from Qt sources -> QTDIR\examples\mainwindows\menus, it's simple, not UI, but once you see it, you'll surely know how to convert ie. My first Qt GUI application to QMainWindow.


No problem. You're welcome.

schuyler   2007-05-03 02:30:47

Hi sector,
Thank you for your answer and examples, you are right!
Thank you again.

Judy   2007-05-02 23:28:20

It is a best tutorial.
Could you add the simple example of QMainWindow ?^^
thank you.

sector   2007-05-02 01:38:07


Thank you. I made this tutorial exactly like the one I wish I had available when I was starting with qt4.


His problem solved by email - he was trying to use commercial qt version, this version doesn't support make/gcc (aka MinGW) but needs MS nmake and MS compiler instead (tools bundled with visual studio).

Adam7   2007-05-02 01:12:46

Great tutorial, You truly know, how make an interesting tut.
Keep on writing other tuts !
Good luck !

George   2007-04-30 21:15:56

hi sector ,
the tutorial is great but it doesnt work for me yet!
i try to do "my first qt GUI application" and when i call make i get the following:
mingw32-make -f Makefile.Debug all
Makefile.Debug:64: *** missing separator. Stop.
mingw32-make[1]: Entering directory `C:/Qt/4.1.4/bin/1'
mingw32-make[1]: Leaving directory `C:/Qt/4.1.4/bin/1'
mingw32-make: *** [debug-all] Error 2
i have all the files of the project in a folder named 1 in the bin dir. i got the .pro file using qmake but i cant get the .exe file
Can you plz help me because i have a project due for school and i cant find nothing online for this problem.
thank you very much in advance!

sector   2007-04-28 11:25:03


I've put there (How to read Qt documentation, basic concepts) zipped sources of that example with custom slot/signal and some words to clarify, check it out.

I suspect you haven't define that slot "mySlot" and you are trying to connect signal to it.

schuyler   2007-04-23 11:51:41

Dear sector,
When I practice examples of "custom signal" in the "How to read Qt documentation, basic concepts", the definition of custom signal does not work.
But examples of "custom slot" can work.
I have no ideal about this. Please help me. Thanks.
My action is below.
a) Added below section into myqtapp.h
void customSignal( const QString& );

b) Added below section into clear() in myqtapp.cpp
emit customSignal( textEdit->toPlainText() );

c) Added below section in constructor myqtapp.cpp
connect( this, SIGNAL( customSignal (const QString&) ), this, SLOT( mySlot(const
QString&) ) );

schuyler   2007-04-17 11:13:50

It is the best tutorial and help me to understand Qt4.
You are the chosen one.
Thank you a bunch.

Carlton   2007-04-11 00:10:18

Fantastic Tutorial, much better than the TrollTech examples. The QT4 examples don't show how you get from the .ui file to the finished code.

Raul   2007-03-07 22:41:35

I absolutely love you. The docking preference, is for gurus like you. THANX

Pavel Slechta   2007-02-11 14:36:43

thanks for this tutorial. It's the best tutorial on Qt I have seen. It helped me a lot.

Happy cross-platform programming.

Rick   2007-01-31 00:45:33

Very nice tutorial, the Drag and drop examples were really useful.

sector   2007-01-24 15:36:49

Hi Mahesh,

Thank you for feedback.

QT designer is just a tool for creating user interfaces (.ui) files, there is no way to get "executable from something done in Qt designer". You need code for your form/dialog to work, and compile it, like it's done in My first Qt GUI application. Actions,.. some hints about actions can be found here, that might help you.

Have a nice day.

Mahesh   2007-01-24 14:58:41

I like your tutorial,but i have question that the app created with QT designer how to compile it or create executable for it?
I'm trying to create simple text editor with it i dont know how to add actions to it?Please post some tutorials related to the QT designer.You are doing great job keep it up.

Cheers mahesh.

sector   2007-01-12 18:44:02

Thank you.

I cleared that point a little bit, adding

"Your PATH environment has to contain i.e C:\MinGW\bin (or whatever path your MinGW/bin is located) in order to proceed."

Make also sure you have MINGW\bin (i.e C:\MinGW\bin) added to your path.

Hope nobody will get stuck on this anymore.

Have a nice day.

Tony   2007-01-12 17:35:50

Hello. Awesome tutorial. BUT I got stuck on the first page. I am a total noob and followed your tutorial very carefully. on this page
The part when you set your variables. PATH QMAKESPEC and QTDIR. I had a probelm here. I dont think QT4 automatically inserts the path to mingw. I had to do this myself. SO of you could please add this to the tutorial PATH C:\MinGW\bin

After I added this line. I could use the configre cmd and use make command. Thanks

Jackson Edau   2006-12-28 13:00:10

Thanks a lot for your time dedicated in preparing this tutorial.

Its really good for Qt4 beginners.

Business Systems Analyst
M+R SPEDAG (Uganda) Ltd

Clive   2006-12-22 11:50:05

Thank you very much!!!
I have spent weeks trying to work all this out and had all but given up.... your tutorial really has saved the day.
Finally I can create an application using qt4 and C++.
Thanks again.

aldin   2006-12-13 23:39:28

thanks for ur work...

tested on ubuntu 6.10 (with KDE & designer-qt4), that zipped file works ok ( i almost gave up of tutorial if i havent tried that zipped file)

thanks again, and i will probably check and the other chapters of this tutorial...

aldin@edgyson:~$ uname -a
Linux edgyson 2.6.17-10-386 #2 Fri Oct 13 18:41:40 UTC 2006 i686 GNU/Linux

Michaël   2006-12-05 09:01:22

Very good tutorial. That's the best tutorial I've ever found on the web !
Go on this way :)

Rochdi   2006-11-22 14:06:08

Very useful tutorial to get statred with QT.

Melix   2006-11-15 10:00:01


Daniel   2006-11-11 00:42:44

Great Site for getting started with Qt4!
Thanks for your effort!
Greetings from Germany

sector   2006-11-05 11:43:52

Thank you all guys for positive feedback, I really appreciate it.

Alex   2006-11-05 05:47:54

Excellent tutorial ! Thanks very much.

Ben   2006-10-29 16:37:07

I suggest everyone using Monkey Studio Qt IDE, it's better than QDevelop.
Free and Open Source

Ben   2006-10-28 19:23:55

Thanks you write this tutorial.

Henri Girard   2006-10-14 16:47:50

Hi :)
I am french and was looking for a starting qt4 tutorial...
I found your tutorial on qtfr and was very pleased as they are really few examples
converting qt3 and qt4 is not really a pleasure...
So i like your work... And specially you put the sources : when they is a problem
we can first see if it compiles on our pc ...
thanks for this wonderfull time of yours

azark   2006-09-21 01:38:00

I found it by using Google and searching for "qt4 tutorial"

sector   2006-09-21 00:52:21

to azark:

Thank you, so nice to hear this. By the way, how did you find this tutorial ?

azark   2006-09-20 16:08:02

Great tutorial (I wish more were like it!) -- haven't been through all of it, but your example and explanations in Part 2 were just what I needed to get things rolling. I usually learn better from seeing examples of code, and your clear explanations completes the process. Keep up the good work!


sector   2006-09-05 02:36:25

to Lucjan:
Thank you very much for positive feedback.

Lucjan   2006-08-28 22:54:57

Very nice tutorial!
The first which I have understood :)
I'am using mingw and your tut is very good for me.
Keep your work, please.

sector   2006-08-17 15:34:36

to amit:
formulation of your problem is very unclear, and english is hard to understood..
My advice is to describe what you want in a clear way and nice english (include also your sources) and post to forum, there are many people willing to help (including myself).
If you don't stick with Qt3, install Qt4 and use this tutorial.
Correct Qt integration into KDE, that is something I can hardly help you with, never done this.


amit   2006-08-17 15:12:34

helo sir how r u
i m amit from pune city india.
i sorry i m mailing u even i dont know u but whn i searching info regarding QT in group i see yr mail id.
actually i m using kde-2.1 and qt-3.3.0 for my project.
i m designing my GUI IN QT for that i creat one project file after that i m creating some files. then i m compiling the project file.
after that i m adding this .ui ,.h and .cpp files inot my kde project.
but it ddint integrate gui
can u tell me how to do inegrate qt and kde in correctly way. i m new in this field.
i try hard but ddint get any help from group
plz if u know then let me know step by step
Thanks and Regrds,

sector   2006-08-17 11:44:22

Use new link
Automatic redirect should already work

quickNitin   2006-08-17 06:41:25

Pages not Found!!!