On 2015-06-10 10:20, Koehne Kai wrote:
> Hi,
> 
> I'm currently converting a codebase from old-style connects to new-style 
> ones. Thanks to Qt Creator's refactoring support this is actually quite easy 
> ... it gets ugly though when either the signal or slot method name is 
> overloaded, and you have to write nice code like
> 
>       connect(&process, static_cast<void 
> (QProcess::*)(QProcess::ProcessError)>(&QProcess::Error), this, 
> &MyClass::processError);

Not exactly what you were getting at, but relating to the overloaded
signals/slots problem in general:

  template<class... Args, class T, class R>
  auto qOverload(R (T::*m)(Args...)) -> decltype(m)
  { return m; }

  connect(&process, qOverload<QProcess::ProcessError>(&QProcess::error),
          this, &MyClass::processError);

In pre-C++11 you can write out explicit flavors for up to however many
arguments you need. Not sure if you can still get return type deduction
that way, though. (I mean in the template argument list... you'd have to
spell out the return type in the helper declaration, obviously.)

-- 
Matthew

_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to