In Qt, a slot is a function that can be connected to a signal. When a signal is emitted, it triggers the connected slot, allowing for a degree of decoupling between objects. Virtual slots, on the other hand, are special types of slots that can be overridden in derived classes. They’re a fundamental concept in Qt’s meta-object system, allowing for maximum flexibility and customization. class MyClass : public QObject { Q_OBJECT public: MyClass(QObject *parent = nullptr) : QObject(parent) {} public slots: virtual void mySlot() { qDebug() << "MyClass::mySlot() called"; } }; By EdaPosted on July 21, 2024