Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Qt classified as a c++ library? If not a library, how would you classify QT?

I recently started looking into Qt (I installed Qt 4.5.2 and installed their Eclipse-CDT plugin called "qt integration v1.5.2" and I will do all my development in Linux-Eclipse-CDT-QTintegration).

Originally I thought Qt was a straight vanilla C++ library but when I installed and started running Qt example code I saw lots of "weird" things that I consider to be non-standard.

My goal is to understand at a high level of abstraction:

  • Is Qt classified as a C++ library?
  • If not a library, how would you classify Qt (analogy/metaphors are appreciated)?
like image 308
Trevor Boyd Smith Avatar asked Sep 02 '09 15:09

Trevor Boyd Smith


2 Answers

Qt is a framework, not a library. This isn't a hard-and-fast distinction enforced by the programming language, rather, it describes how the code is designed and intended to be used:

A library is someone else's code that is used by your code. Using a library means that your application remains as it is, it just has another library to help it out.

A framework is someone else's code that your code fits into. Using a framework means that the framework defines the structure of your application.

If you're using a framework, you need to learn that framework's conventions, which may be a bit different than the base language; otherwise, you can spend a lot of time fighting the framework, and you'll be missing out on some of what it has to offer.

Qt in particular doesn't look like straight vanilla C++ because it isn't straight vanilla C++. It adds (limited) extensions to C++'s object system to permit features like signals and slots; these extensions are implemented using Qt's moc, which acts as a C++ preprocessor. For more information on Qt's extensions to C++:

  • Meta-Object System
  • Why Doesn't Qt Use Templates for Signals and Slots?
like image 173
Josh Kelley Avatar answered Nov 09 '22 16:11

Josh Kelley


Qt is a set of C++ libraries along with a preprocessor and part of a build system.

like image 24
Amok Avatar answered Nov 09 '22 15:11

Amok