Results 1 to 6 of 6

Thread: Some general questions on Qt

  1. #1
    Join Date
    Jan 2016
    Posts
    76
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Some general questions on Qt

    Hello all,

    I'm eager to hear from you some simple explanations on the terms below. I know, that there are many great links dealing with those items but they're mostly bewildering for a newbie. If possible, provide me with what you know about them in simple language so that I can completely understand them:

    1) What is/are the compiler(s) of Qt when we're writing program on Qt Creator?
    2) What are moc, cmake, and qmake?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Some general questions on Qt

    Quote Originally Posted by franky View Post
    1) What is/are the compiler(s) of Qt when we're writing program on Qt Creator?
    The most common compilers used with QtCreator are GCC, CLang and MSVC (Microsoft C++ Compiler))

    Quote Originally Posted by franky View Post
    2) What are moc, cmake, and qmake?
    MOC is a code generator that reads header files and generates C++ code that contains meta data for things defined in these headers.
    For example for QObject based classes this meta data contains the class name, signatures of signals and slot, properties and enums.

    CMake and QMake are build systems, the generate instructions on how to build programs.
    They can do so across many different compilers and operating systems.

    QMake is currently used by Qt for building Qt itself and often used by projects using Qt.

    CMake is one of the most often used build systems for C++ applications, whether they are using Qt or not.
    Qt will likely switch to using CMake as its main build system with Qt6.

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    franky (15th July 2019)

  4. #3
    Join Date
    Jan 2016
    Posts
    76
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Some general questions on Qt

    thank you very much for your answers.

    The most common compilers used with QtCreator are GCC, CLang and MSVC (Microsoft C++ Compiler))
    How about MinGW, please?

    I'm using Qt 5.12.3. In the Build menu, I have got run qmake also in the Options menu section Build & Run, I have Cmake. What do these mean please?

  5. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,141
    Thanks
    235
    Thanked 661 Times in 651 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Some general questions on Qt

    How about MinGW, please?
    MinGW stands for "Minimalist GNU for Windows". It is an implementation of the GNU unix clone that runs in a Windows host OS. By default, MinGW uses the gcc (GNU Compiler Collection) C / C++ compiler.

    As anda_skoa explained, cmake is a build system. It is a program that reads a file (CMakeLists.txt) containing a set of commands that describes the source files in your program and other parameters / options needed to build the program, library, or whatever else it is you are trying to build. It writes out either a Makefile (for using "make" with gcc and similar compilers), a similar Makefile file (for using "nmake" with Microsoft C/C++ compiler), or a set of solution (.sln) and project (.vcxproj) files (for Microsoft Visual Studio). cmake can be run from the command line with command line options to specify whether you want to generate Makefiles or build certain targets or configurations within them.

    For example, when you use cmake and specify Visual Studio project output files, it will generate a targets called "ALL_BUILD" and "INSTALL", among others. Running cmake to build the ALL_BUILD target will compile and link all of the programs / libraries / whatever that have been defined via the CMakeLists.txt file. Running cmake with the INSTALL target will copy programs / libraries / whatever into the locations you have defined for installation (a bin directory for executables and DLLs, lib directory for link libraries, an include directory for .h files, etc).

    qmake is similar. It takes the instructions written in your project's .pro / .pri files and writes out Makefiles appropriate for whatever compiler and linker toolchain you are using. It is generally used in conjunction with Qt Creator, which automates this process through your kit configuration and Build menu, but qmake can be run stand-alone and the Makefiles can be used by the proper build tool (make, nmake) outside of Qt Creator.

    If you do not have cmake installed, if the project you are trying to build does not have a CMakeLists.txt file that describes how to build it, and if you don't know how to write one, then you don't want to use cmake. Qt Creator (and other IDEs) contain the tools to build project based on cmake descriptions if that's the way your project is set up.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  6. The following user says thank you to d_stranz for this useful post:

    franky (30th July 2019)

  7. #5
    Join Date
    Jan 2016
    Posts
    76
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Some general questions on Qt

    @anda_skoa
    MOC is a code generator that reads header files and generates C++ code that contains meta data for things defined in these headers.
    For example for QObject based classes this meta data contains the class name, signatures of signals and slot, properties and enums.
    So MOC is actually a bridge between the bass class and derived ones to provide them with the (.cpp) facilities the bass class (.h) offers, right?

    @d_stranz
    So Cmake/qMake build a makefile for the compiler, in summary. Right?


    My compilers are listed below and I also posted my kits. So for Desktop apps I'm now using the MinGW which is naturally GCC and for Android I'm using the CLang compiler.

    3.jpg 4.PNG

    So my question for this spot is that, I know when my compilers is fetch to work but how should I know what build system is working for my projects? I just hit Run!

  8. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,141
    Thanks
    235
    Thanked 661 Times in 651 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Some general questions on Qt

    So MOC is actually a bridge between the bass class and derived ones to provide them with the (.cpp) facilities the bass class (.h) offers, right?
    No, MOC is a code generator that detects the Q_OBJECT macro in a .h file and generates a .cpp file that contains all of the boilerplate code needed to implement what is needed for the Qt Meta-Object system - signals, slots, run-time identification, etc. This cpp file gets compiled and linked into your program along with the .h and .cpp files you have hand-coded for your Qt classes.

    So Cmake/qMake build a makefile for the compiler, in summary. Right?
    Basically, although cmake is much more powerful than that. cmake can download code from git or another repository, find where the libraries and include files for code that your program uses are installed on your PC, generate build instructions for different platforms and configurations, create an installer, and more.

    how should I know what build system is working for my projects?
    I don't use Qt Creator very often, but it should be whatever kit(s) you have selected for that project when you configured it. If you hover the mouse over the Debug icon (above Run on my copy of Qt Creator), it will show you the kit it is currently using if you have configured more than one. You can change between kits on the Projects page by clicking on the appropriate tab at the top of the page.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  9. The following user says thank you to d_stranz for this useful post:

    franky (1st August 2019)

Similar Threads

  1. General question Spectrogram plot
    By QTim in forum Qwt
    Replies: 6
    Last Post: 6th January 2014, 19:42
  2. General destroy question
    By qlands in forum Qt Programming
    Replies: 2
    Last Post: 16th September 2011, 08:10
  3. Drag and Drop General Question
    By onurozcelik in forum Qt Programming
    Replies: 0
    Last Post: 19th August 2010, 14:22
  4. General question about events overriding
    By mattc in forum Qt Programming
    Replies: 2
    Last Post: 14th September 2009, 15:35
  5. General Question about Qt4 Model/View
    By reed in forum Qt Programming
    Replies: 2
    Last Post: 13th May 2008, 15:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.