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.0.
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..
If you took upper-most floor of WTC and dropped it, it would fall through air and hit the ground in time about 10 seconds. Time of real WTC collapse was about 10 seconds! Watch video to confirm. Can debris fall through steel columns and concrete floors as fast as it would fall through air ?
Under zone of aircraft impact WTC Towers had 75/90 undamaged floors. How is it possible that this undamaged part of the building, which always had born weight of the upper floors with no problem, during the collapse provided virtually NO resistance to the section above ?
Look at this videos of WTC "collapse": video1, video2. Isn't what we see a building exploding to dust from top to bottom ?
On September 11th, 2001, third skyscraper, WTC 7 collapsed several hours after WTC Towers came down, allegedly due to fire and damage. Watch videos of this collapse:
video1,
video2,
video3.
There is no way fire/damage could cause this swift, systematic, straight-down collapse, and transform huge 47-floor steel structure into a small pile of rubble in matter of seconds. This building was brought down by professional controlled demolition. Official reports say that fire/damage caused this.
Watch technical analysis of WTC collapse by Richard Gage - architect with 20+ years experience with buildings design/construction
I want to say a word of thanks to following people for helping me with this tutorial:
azark - for correcting the grammar and typos
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
Name
Email
not mandatory (login@server.com will be changed to na login [ at ] server.com 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:
Ed2008-11-13 23:07:55
Hi,
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.
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.
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
hi: 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 thanks
sector2008-09-02 22:54:56
Hi,
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.
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.
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.
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
Aroni2008-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
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
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.
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
Great!
Karl2008-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'.
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. :)
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.Ander2008-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...
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 filebrowser6.pro [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
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
hi 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 etc
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.
Just mentioning that you forgot a few links : * Edyuk (IDE for Qt 4) : http://edyuk.org * Cobras (yet another IDE for Qt 4) : http://beesoft.org/cobras.html * QtNode (wiki and IRC channel) : http://qtnode.net * QtFr.org (french "equivalent" of QtCentre : forum, wiki, news, ...) : http://qtfr.org
there are probably even more but these are by far the most useful IMO.
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.
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.
Cheers,
md
sector2007-06-29 13:06:09
Durgesh:
I have unfortunately never used Qtopia, so I'm unable to give any links/recommendations about it.
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.
Qt 4.2.3 Runtime Installer for windows: http://c9s.blogspot.com/2007/06/qt-runtime-installer-for-windows-full.html
sector2007-05-31 10:25:56
Jessica
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: QtCore4.so QtGui4.so
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.
Jessica2007-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 ^_^
sector2007-05-27 22:28:01
Roberto: thanks
Jessica
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 libQtGui.so.4) 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)
Great!!! I have learned How to programming using Qt4 reading your tutorial. A very nice tutorial for beginners. Good Work!!!
Jessica2007-05-11 09:39:42
Hi, 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 libraries:libQtGui.so.4". I don't know what happend. Could you help me, please? Are there any suggestion? Thank you..
sector2007-05-03 21:04:18
Judy:
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.
schuyler:
No problem. You're welcome.
schuyler2007-05-03 02:30:47
Hi sector, Thank you for your answer and examples, you are right! Thank you again.
Judy2007-05-02 23:28:20
It is a best tutorial. Could you add the simple example of QMainWindow ?^^ thank you.
sector2007-05-02 01:38:07
Adam7:
Thank you. I made this tutorial exactly like the one I wish I had available when I was starting with qt4.
George:
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).
Adam72007-05-02 01:12:46
Great tutorial, You truly know, how make an interesting tut. Keep on writing other tuts ! Good luck !
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: C:\Qt\4.1.4\bin\1>make 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!
sector2007-04-28 11:25:03
Hi,
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.
schuyler2007-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 signals: 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&) ) );
Very nice tutorial, the Drag and drop examples were really useful.
sector2007-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 http://doc.trolltech.com/4.2/mainwindows-application.html, that might help you.
Hi 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.
sector2007-01-12 18:44:02
Thank you.
I cleared that point a little bit, adding
MinGW: "Your PATH environment has to contain i.e C:\MinGW\bin (or whatever path your MinGW/bin is located) in order to proceed."
Qt: Make also sure you have MINGW\bin (i.e C:\MinGW\bin) added to your path.
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 http://sector.ynet.sk/qt4-tutorial/preparations.html 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
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.
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 cheers Henri
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!
Don
sector2006-09-05 02:36:25
to Lucjan: Thank you very much for positive feedback.
Lucjan2006-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.
sector2006-08-17 15:34:36
to amit: Hello, 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 http://www.qtcentre.org 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.
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 nsgui.pro 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, Amit