Qt moc FAQ Interview Questions

Q) What is Qt ?
Qt is a cross-platform application framework that is widely used for developing application software that can be run on various software and hardware platforms with little or no change in the underlying codebase,
Q) What is a framework?
framework  is an essential supporting structure of a building, vehicle, or object.
. Frameworks are a special case of software libraries in that they are reusable abstractions of code wrapped in a well-defined Application programming interface (API), which is overriden by user.
.Frameworks  is an abstraction in which common code providing generic functionality can be selectively overridden or specialized by user code providing specific functionality
Framework->uses your code.
Library->you use library code.
Q) What is qmake?
qmake is a utility that automates the generation of Makefiles.
Makefiles are used by the program make to build executable programs from source code; therefore qmake is a make-makefile tool, or makemake for short.
QMake does not call g++/gcc directly. Instead, qmake creates native make files on your current platform. Under linux it creates standard GNU make files, under windows it can generate visual studio make files, under Mac OS X it can generate XCode project files. You then invoke your native build system (either GNU make, or MS NMake, or xcodebuild or whatever), which will call your native compiler (g++/gcc or whatever).
Q) What is Qt and Qml ?
Qt is a cross-platform application framework.
QML is the name of the language (just like C++, which is another language...)
QML stands for Qt Meta Language or Qt Modelling Language is a user interface markup language.
QtQuick is a toolkit for QML, allowing to develop graphical interface in QML language (there are other toolkits for QML, some are graphical like Sailfish Silica or BlackBerry Cascade, and some are non-graphical like QBS which is a replacement for QMake/CMake/make...)
QtQuick 1.x was Qt4.x-based and used the QPainter/QGraphicsView API to draw the scene. QtQuick 2.X was introduced with Qt5.0, based on Scene Graph, an OpenGLES2 abstraction layer, highly optimized.
With Qt5.1, Scene Graph was enhanced to use multithreading (QtQuick 2.1) With Qt5.2,
Q)What is Qt's meta object system?
Qt's meta-object system provides the signals and slots mechanism for inter-object communication, run-time type information, and the dynamic property system.
The meta-object system is based on three things:
1. The QObject class provides a base class for objects that can take advantage of the meta-object system.
2. The Q_OBJECT macro inside the private section of the class declaration is used to enable meta-object features, such as dynamic properties, signals, and slots.
3. The Meta-Object Compiler (moc) supplies each QObject subclass with the necessary code to implement meta-object features.
The moc tool reads a C++ source file. If it finds one or more class declarations that contain the Q_OBJECTmacro, it produces another C++ source file which contains the meta-object code for each of those classes.
Q)What is moc? http://doc.qt.io/qt-4.8/moc.html
The Meta-Object Compiler, moc, is the program that handles Qt's C++ extensions.
The moc tool reads a C++ header file.
1>If it finds one or more class declarations that contain the Q_OBJECT macro, it produces a C++ source file containing the meta-object code for those classes.and
2>meta-object code is required for the signals and slots mechanism and
3>moc is required for run-time type information, and the dynamic property system.
Note:
The C++ source file generated by moc must be compiled and linked with the implementation of the class.
But,If you use qmake to create your makefiles, build rules will be included that call the moc when required, so you will not need to use the moc directly.
Q) can moc file handle all class type?
No, class template can not have signal slot. can not be handled by moc.
Q) What are limitations of moc:
moc does not handle all of C++.e.g.
The main problem is that class templates cannot have signals or slots.
Function Pointers Cannot Be Signal or Slot Parameters
Type Macros Cannot Be Used for Signal and Slot Parameters
Nested Classes Cannot Have Signals or Slots
Signal/Slot return types cannot be references
Q) What is Qvariant?
QVariant is a container of variables. It can store variables of different types. Similar in some way to void*. But it provides You information about the stored type.
It can be used for example to return different types of values from a function.
Q)What is moc?
The Meta-Object Compiler, moc, is the program that handles Qt's C++ extensions.
The moc tool reads a C++ header file.
1>If it finds one or more class declarations that contain the Q_OBJECT macro, it produces a C++ source file containing the meta-object code for those classes.and
2>meta-object code is required for the signals and slots mechanism and
3>moc is required for run-time type information, and the dynamic property system.
Note:
The C++ source file generated by moc must be compiled and linked with the implementation of the class.
But,If you use qmake to create your makefiles, build rules will be included that call the moc when required, so you will not need to use the moc directly.
 http://doc.qt.io/qt-4.8/moc.html

No comments:

Post a Comment