Understanding QObject in Qt

#ifndef TEST_H#define TEST_H#include <QObject>class Test : public QObject{Q_OBJECTpublic:   explicit Test(QObject *parent = nullptr);signals:};#endif // TEST_H
#ifndef TEST_H#define TEST_Hclass Test{public:};#endif // TEST_H

Including QObject and inheriting it


Signals and slots

Q_OBJECT macro

explicit Test(QObject *parent = nullptr);

“The Q_OBJECT macro must appear in the private section of a class definition that declares its own signals and slots or that uses other services provided by Qt’s meta-object system.”

Awarded Content Creator in the 2020 Qt Champion Awards:

“Bryan has a few courses available on Udemy, specifically his course on Qt 5 Design Patterns and also has a popular group on Facebook which helps others with their Qt questions as well. For his work alone in creating the Qt 5 training course online for everyone to benefit from it was easy to make him our year’s Content Creator.”



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store