Signal inside an abstract class
Hi there guys. I have this abstract class below.
Code:
{
Q_OBJECT
public:
explicit Page
(QObject *parent
= 0);
virtual void start_downloading() = 0;
signals:
void done();
public slots:
};
As you can see that there is a signal Page::done() in the class. I have a bunch of concrete classes that inherit this class and the concrete classes will emit the signal Page::done() above. I have a separate class that works with the concrete classes and problem is connecting the above signal to any slot and I suppose its because the signal exists in an abstract class. Is there a way of connecting this signal.
Re: Signal inside an abstract class
The concrete classes inheriting abstract Page class will also inherit the signals (and slots), so connecting to signal should be just as usual, should not be any different for Abstract class signal (or slot) / Concrete class signal (or slot).
Re: Signal inside an abstract class
The "signals" keyword is basically defining a "protected" section in the class definition, so your derived classes will inherit the methods you have defined as signals with protected access.
You may have to qualify the names with Page:: when you connect (and use the "PointerToMemberFunction" version of QObject::connect()).
Re: Signal inside an abstract class
Quote:
Originally Posted by
d_stranz
The "signals" keyword is basically defining a "protected" section in the class definition
Actually Qt5 had to switch this to "public" in order to make the function pointer based connect work.
Cheers,
_
Re: Signal inside an abstract class
Quote:
Actually Qt5 had to switch this to "public" in order to make the function pointer based connect work.
Hmm, I must have been looking at older documentation. Making it public makes sense, though. Thanks for the correction.