[Interest] Odd new-style connect()/disconnect() error with Qt 5.5.0

Matthew Woehlke mwoehlke.floss at gmail.com
Thu Oct 15 15:50:37 CEST 2015


On 2015-10-15 03:11, André Somers wrote:
> I am using this little helper for those cases:
> 
> //tricktomakeconnectingwithQt5-styleconnectstooverloadedsignals
> template <typename...Args> struct SELECT {
>   template <typenameC, typenameR>
>   static constexpr auto OVERLOAD_OF(R(C::*pmf)(Args...)) -> decltype(pmf) {
>     returnpmf;
>   }
> };

My version is less typing :-).

> connect(stream.data(),
> SELECT<QAbstractSocket::SocketError>::OVERLOAD_OF<QTcpSocket::error>,
>         this,  &TCPChannel::slot_socket_error);

  connect(stream.data(),
          qtOverload<QAbstractSocket::SocketError>(&QTcpSocket::error),
          this, &TCPChannel::slot_socket_error);

(Pedantic: I do believe the '&' is supposed to be unnecessary, although
usually preferred for style reasons.)

-- 
Matthew




More information about the Interest mailing list