So let's suppose I've got a regular Qt class MyQtClass
and a class MyClass
with ONLY static members. If I want to access the ui of MyQtClass
I have to use Signals and Slots. So I create a static Signal (static so I can just invoke it like MyClass::mySignal();
) and a slot in the Qt class. How can I connect the static signal from MyClass with the slot from the Qt class, without having an object of MyClass
, since it has only got static members?
I know that classes with only static members isn't considered as a good design in c++ but I'm too far into the project by now and I want to know if there's a way to do it with only static members.
Thanks in Advance!
Code:
MyQtClass.h:
#include "ui_MyQtClass.h"
class MyQtClass : public QMainWindow
{
Q_OBJECT
public:
MyQtClass(QWidget *parent = Q_NULLPTR);
Q_SLOT void mySlot();
private:
Ui::MyQtClassClass ui;
};
MyClass.h:
#pragma once
#include <QtWidgets/QMainWindow>
class MyClass : public QObject
{
public:
static void myFunction1();
static void myFunction2();
/*--- More Stuff ---*/
Q_SIGNAL static void mySignal();
};