PDA

View Full Version : Learning Path for Qt



phil_n
28th March 2014, 04:50
Hi all

I have some general knowledge of C++ picked up 20 yrs ago in programming courses. I have done some javascript, php and sql, and bits of BASIC and VisualBasic. I am trying to learn Qt 'from the ground up'. The examples and tutorials I have found are mostly for versions <5.2 and suffer from an almost complete lack of explanation. In the 'textedit' example there is a line - #include "ui_textfinder.h" - wherein a file (ui_textfinder.h) is included that doesn't appear to exist and there is no real explanation of where this came from or where it is, just some vague reference to possibly being auto-generated by uic. And that's just an example of what I've been running into everywhere - or just plain outdated.

So my question is this: Where do I go to start at "Hello World" and work up from there with clear and unambiguous explanations of what's going on? A good text? I have "An Introduction to Design Patterns in C++ with Qt - 2nd ed" and it's like What? - this is not for beginners! Up-to-date on-line tutorials?

Any help would be greatly appreciated (I've been swimming round and round in circles for months).

rawfool
28th March 2014, 06:09
This is exactly what you need - http://www.voidrealms.com/index.php?r=tutorial/index
In there, under Language tab, there's a dropdown box (we call it QComboBox in Qt), select the option Qt.
For any doubts related to Qt classes, check the documentation.

phil_n
28th March 2014, 08:00
Thank you. Looks good. :)

Infinity
28th March 2014, 19:46
In the 'textedit' example there is a line - #include "ui_textfinder.h" - wherein a file (ui_textfinder.h) is included that doesn't appear to exist and there is no real explanation of where this came from or where it is, just some vague reference to possibly being auto-generated by uic.
This page of the Qt documentation might answer your question: https://qt-project.org/doc/qt-5.0/qtdesigner/designer-using-a-ui-file.html
In my opinion the documentation of Qt is good (comparing to other libraries).
This tutorial is worth a look as well: http://www.digitalfanatics.org/projects/qt_tutorial/

phil_n
31st March 2014, 00:07
Thank you all for your help and suggestions. You are probably right about the docs being pretty good - they certainly are extensive, but they really aren't for 'beginners'; sort of like unix man pages. I'm sure once one gets a better understanding of the fundamentals they are invaluable.

This might be drifting a little off topic but as it's already been discussed: Is the include file ui_foo.h 'persistent' or is it a 'virtual' file created temporarily by uic? The way I undersand it looks like uic generates the file 'in memory' which is then used further down the build chain and then destroyed after the build is completed. I only say this because I can find no evidence of it in the project folder or on my hard drive.

TIA

stampede
31st March 2014, 07:55
The way I undersand it looks like uic generates the file 'in memory' which is then used further down the build chain and then destroyed after the build is completed
You are right, uic generates ui_*.h files during compilation (using information from *.ui forms), but "ui_" files are not removed from disk - except if you call "make clean" or "make distclean". You can choose a directory for ui_*.h files by setting "UI_DIR=path" in .pro file.

phil_n
1st April 2014, 03:05
Found it in the 'build' directory.

Radek
1st April 2014, 07:41
The ui_*.h file(s) are generated from the *.ui files during building your application. You are not writing the ui_*.h files. The file(s) are not removed from the disk after building the app. They are used for compiling (C++) your app. They are registered in the makefile and redone every time the corresponding *.ui file change.

You need to #include the the ui_*.h file(s) in your code, even if "they do exist" to trigger an "on demand" building them. The files contain C++ classes made from the *.ui files.

As to Qt: there are 4 books on the web (PDF files) which help greatly:

(1) Blanchette, Summerfield - C++ GUI programming with Qt4. A good starting point.
(2) Molkentin - A Book of Qt4. Another good starting point.
(3) Ezust, Ezust - An Introduction to Design Patterns in C++ with Qt. A basic knowledge of Qt classes is helpful when reading this.
(4) Summerfield - Advanced Qt programming. Not a "starting point". A very good book but read later.