On Wednesday, 21 de September de 2011 16.06.13, Peter Kuemmel wrote:
> One way around it would be "on-the-fly inheriting":
> 
> https://qt.gitorious.org/~syntheticpp/qt/qtbase-staging-improvements/commit/
> c1cf86f08fca7efbbf03106756d4c5bbd991664c
> 
> Maybe this commit could be the starting point for a better
> 'QObject::connect' replacement.

If you can do on-the-fly inheritance to access a protected in order to connect, 
you can also do it to emit the signal. And you can do that today in Qt 4 (like 
Q3DnsUgleHack 
<https://qt.gitorious.org/qt/qt/blobs/master/src/qt3support/network/q3dns.cpp#line806>)

If I get you correctly, you want the syntax to be:

        connect<SenderClass>::signalName(senderObject, receiverObject, 
                &ReceiverClass::slotFunction);

However, there's a fatal flaw in that design: you need the connect<SenderClass> 
class to be entirely defined in the header. Your code has (line 4494ff):
  4494  /*
  4495      generated by moc
  4496  */
  4497  template<>
  4498  struct connect<ProtectedSignal>

You need to move this struct to the header, which means either boilerplate 
code written by the developer or an include of a moc-generated file in a public 
header. Both options would suck IMHO.

Another option is to use macros:

class MyClass
{
    Q_OBJECT
    Q_SIGNAL(signalName, (const QString &textChanged, int changeCount))
};

With something like:
#define Q_SIGNAL(name, args) \
    protected: name args; \
    public: name ## _connect args; \
    private:

And make moc generate these two functions. We'd have the connection as:

    QObject::connect(sender, &MyClass::signalName_connect, receiver, [](){});

and the emission:
    emit signalName(newText, ++count);

I don't like it either.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Qt5-feedback mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt5-feedback

Reply via email to