[Interest] connecting to QObject member of QProcess

Sze Howe Koh szehowe.koh at gmail.com
Thu Sep 25 15:12:22 CEST 2014


On 25 September 2014 10:20, Thiago Macieira <thiago.macieira at intel.com> wrote:
> On Wednesday 24 September 2014 19:19:13 Thiago Macieira wrote:
>> On Thursday 25 September 2014 09:37:49 nus1998 wrote:
>> > Hi All,
>> >
>> > I met a issue when use the new connecting method, in my code:
>> > connect(m_process,&QProcess::finished,this,&Dialog::done);
>> > which will cause a error as follow:
>> > error: no matching function for call to 'Dialog::connect(QProcess*&,
>> > <unresolved overloaded function type>, Dialog* const, void (Dialog::*)())'
>> > connect(m_process, &QProcess::finished, this, &Dialog::done); ^
>> > But the other signal such as "readyReadStandardOutput" works fine in this
>> > new connecting method. and if I change to old method as:
>> > connect(m_process,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(don
>> > e
>> > ())); It works with no problem too.
>> > Anything I did wrong?
>>
>> C++ problem. There are two functions called QProcess::finished. You need to
>> tell the compiler which one you want.
>>
>> connect(m_process, static_cast<void (QProcess::*)()>(&QProcess::finished),
>>       this, &Dialog::done);
>
> Make that:
> connect(m_process, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
>         this, &Dialog::done);

This is now formally documented, along with other differences between
the old and new connection syntaxes:
http://doc-snapshot.qt-project.org/qt5-5.4/signalsandslots-syntaxes.html

(For this particular use-case, see the section "Selecting Overloaded
Signals and Slots")


Regards,
Sze-Howe



More information about the Interest mailing list