connect pure-virtual SIGNAL of an abstract class to a SLOT from constructor

77 views Asked by At

I have an abstract class that contains the pure virtual signal and a class derived from qobject. Now I want to connect that signal to derived class's slot. Please see the following code to be clear:

msys.h

class MSys : public QObject
{
    Q_OBJECT
public:
    explicit MSys(QObject *parent = 0) : QObject(parent) {}
    virtual ~MSys() {}

public slots:
    void onRequset();
};

absview.h

class AbsView
{
protected:
    AbsView() : m_sys(new MSys)
    {
        // QObject::connect(this, SIGNAL(request()), m_sys, SLOT(onRequset()));
        /* What can I do here !? */
    }

public:
    virtual ~AbsView() {}

signals:
    virtual void request() = 0;

private:
    MSys *m_sys;
};

Q_DECLARE_INTERFACE(AbsView, "AbsView")

Thanks for your time.

Edit: My question just been marked as duplicate comparing with the question that says " Declare abstract signal in interface class ". But I think that my question clearly says that connect abstract signal to a slot.

0

There are 0 answers