[Interest] Interface with signals and slots

Konstantin Shegunov kshegunov at gmail.com
Fri Nov 30 22:28:57 CET 2018


Hi,
This compiles for me:

class SignalInterface

{

public:

    virtual void mysignal() = 0;

};


class SignalImplementer : public QObject, public SignalInterface

{

    Q_OBJECT


signals:

    void mysignal() override;

};


However putting signals into an interface I think is rather dubious,
because you won't be able to connect through the interface. I.e. this:

SignalImplementer obj;

QObject::connect(this, &Session::opened, &obj, &SignalInterface::mysignal);


Is going to fail the static assertions in QObject::connect.
You could derive from QObject though and have them in an abstract class.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181130/4ff968a1/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image013.jpg
Type: image/jpeg
Size: 6751 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181130/4ff968a1/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image014.jpg
Type: image/jpeg
Size: 1016 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181130/4ff968a1/attachment-0001.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image015.png
Type: image/png
Size: 483 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181130/4ff968a1/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image016.png
Type: image/png
Size: 506 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181130/4ff968a1/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image017.png
Type: image/png
Size: 500 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181130/4ff968a1/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image018.jpg
Type: image/jpeg
Size: 713 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181130/4ff968a1/attachment-0002.jpg>


More information about the Interest mailing list