Connect to QBluetoothSocket::error signal using new style connect
-
I ran into a compile error when trying to connect to QBluetoothSocket::error using connect new style (function pointers):
@
connect(socket, &QBluetoothSocket::error, this, &QBluetoothCommunicator::socketError);
@My class is called QBluetoothCommunicator and has a slot with the following signature:
@
void socketError(QBluetoothSocket::SocketError error);
@GCC (4.9) is giving me the following errors when compiling:
@
QBluetoothCommunicator.cpp:170:96: error: no matching function for call to 'QBluetoothCommunicator::connect(QBluetoothSocket*&, <unresolved overloaded function type>, QBluetoothCommunicator*, void (QBluetoothCommunicator::*)(QBluetoothSocket::SocketError))' connect(socket, &QBluetoothSocket::error, this, &QBluetoothCommunicator::socketError);
@It seems that the error is caused by the fact that QBluetoothSocket has a method called error also, which can be used to fetch an error:
@
[...]
SocketError error() const;QSIGNALS:
void error(QBluetoothSocket::SocketError error);
[...]
@When using the old style connect, there is no problem.
@
connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(socketError(QBluetoothSocket::SocketError)));
@Am I overlooking something?
-
Hi and welcome to devnet,
QBluetoothSocket has more than one function called error. You need to tell which overload you are using.
You have an example "here":http://qt-project.org/wiki/New_Signal_Slot_Syntax