Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Connect to QBluetoothSocket::error signal using new style connect
Forum Updated to NodeBB v4.3 + New Features

Connect to QBluetoothSocket::error signal using new style connect

Scheduled Pinned Locked Moved Mobile and Embedded
2 Posts 2 Posters 745 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jbvo
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved