Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Error: no matching function for asynccall in qdbusabstractinterface

Error: no matching function for asynccall in qdbusabstractinterface

Scheduled Pinned Locked Moved Unsolved General and Desktop
qdbusqdbusinterfaceqvariant
2 Posts 2 Posters 190 Views
  • 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.
  • A Offline
    A Offline
    AROH
    wrote on 28 Mar 2024, 07:05 last edited by
    #1

    I am trying to pass a array of int as one of the parameter in QDBusPendingCall asyncCall = interface.asyncCall("Message", type, indices, message); where interface is QDBusInterface object. And the parameters type is of int, indices is of array of int and message is of qString.

    To pass as array of int, I have tried with std::array<int,1> , QList<int> and QVector<int>. For all three ways, I am getting the below error during build process.

    error: no matching function for call to 'QVariant::QVariant(QVector<int>&)'
    |   168 |         const QVariant variants[] = { QVariant(std::forward<Args>(args))... };
    |       |                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

    This error traces back to qdbusabstractinterface.h file in QT.

    But if I try with passing a value directly in the function call, there is no such error during build process.

    Below is the sample app i have tried to demonstrate the error that i am facing.

    myclass.h**
    
    #ifndef MYCLASS_H
    #define MYCLASS_H
    
    #include <QObject>
    #include <QDBusInterface>
    #include <QDBusPendingCallWatcher>
    #include <QVector>
    
    class MyClass : public QObject
    {
        Q_OBJECT
    
    public:
        explicit MyClass(QObject *parent = nullptr);
    
    public slots:
        void performDistributedCalculation(int type, QVector<int> indices, QString message);
    
    private slots:
        void handleDBusReply(QDBusPendingCallWatcher *watcher);
    
    private:
        QDBusInterface interface;
    };
    
    #endif // MYCLASS_H
    
    **myclass.cpp**
    
    #include "myclass.h"
    
    MyClass::MyClass(QObject *parent) : QObject(parent)
    {
        // Create the D-Bus interface
        interface = new QDBusInterface("com.example.MyService", "/MyObject", "org.example.MyInterface", QDBusConnection::sessionBus(), this);
    }
    
    void MyClass::performDistributedCalculation(int type, QVector<int> indices, QString message)
    {
        // Asynchronously call the D-Bus method
        QDBusPendingCall asyncCall =interface.asyncCall("Message", type, indices, message);
    
        // Connect the reply handler
        QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(asyncCall, this);
        connect(watcher, &QDBusPendingCallWatcher::finished, this, &MyClass::handleDBusReply);
    }
    
    void MyClass::handleDBusReply(QDBusPendingCallWatcher *watcher)
    {
        QDBusPendingReply<int> reply = *watcher;
        if (reply.isError()) {
            qDebug() << "Error calling D-Bus method:" << reply.error().message();
        } else {
            int result = reply.value();
            qDebug() << "Received result from D-Bus:" << result;
            // Handle the result as needed
        }
    
        watcher->deleteLater();
    }
    
    **main.cpp**
    
    #include <QCoreApplication>
    #include "myclass.h"
    
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
    
        MyClass myObject;
        myObject.performDistributedCalculation(2 , {1,2}, "HELLO, I am fine");
    
        return a.exec();
    }
    

    Any help on the same would be great !!

    Thanks in advance !!

    Regards,
    AROH

    J 1 Reply Last reply 28 Mar 2024, 07:10
    0
    • A AROH
      28 Mar 2024, 07:05

      I am trying to pass a array of int as one of the parameter in QDBusPendingCall asyncCall = interface.asyncCall("Message", type, indices, message); where interface is QDBusInterface object. And the parameters type is of int, indices is of array of int and message is of qString.

      To pass as array of int, I have tried with std::array<int,1> , QList<int> and QVector<int>. For all three ways, I am getting the below error during build process.

      error: no matching function for call to 'QVariant::QVariant(QVector<int>&)'
      |   168 |         const QVariant variants[] = { QVariant(std::forward<Args>(args))... };
      |       |                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      

      This error traces back to qdbusabstractinterface.h file in QT.

      But if I try with passing a value directly in the function call, there is no such error during build process.

      Below is the sample app i have tried to demonstrate the error that i am facing.

      myclass.h**
      
      #ifndef MYCLASS_H
      #define MYCLASS_H
      
      #include <QObject>
      #include <QDBusInterface>
      #include <QDBusPendingCallWatcher>
      #include <QVector>
      
      class MyClass : public QObject
      {
          Q_OBJECT
      
      public:
          explicit MyClass(QObject *parent = nullptr);
      
      public slots:
          void performDistributedCalculation(int type, QVector<int> indices, QString message);
      
      private slots:
          void handleDBusReply(QDBusPendingCallWatcher *watcher);
      
      private:
          QDBusInterface interface;
      };
      
      #endif // MYCLASS_H
      
      **myclass.cpp**
      
      #include "myclass.h"
      
      MyClass::MyClass(QObject *parent) : QObject(parent)
      {
          // Create the D-Bus interface
          interface = new QDBusInterface("com.example.MyService", "/MyObject", "org.example.MyInterface", QDBusConnection::sessionBus(), this);
      }
      
      void MyClass::performDistributedCalculation(int type, QVector<int> indices, QString message)
      {
          // Asynchronously call the D-Bus method
          QDBusPendingCall asyncCall =interface.asyncCall("Message", type, indices, message);
      
          // Connect the reply handler
          QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(asyncCall, this);
          connect(watcher, &QDBusPendingCallWatcher::finished, this, &MyClass::handleDBusReply);
      }
      
      void MyClass::handleDBusReply(QDBusPendingCallWatcher *watcher)
      {
          QDBusPendingReply<int> reply = *watcher;
          if (reply.isError()) {
              qDebug() << "Error calling D-Bus method:" << reply.error().message();
          } else {
              int result = reply.value();
              qDebug() << "Received result from D-Bus:" << result;
              // Handle the result as needed
          }
      
          watcher->deleteLater();
      }
      
      **main.cpp**
      
      #include <QCoreApplication>
      #include "myclass.h"
      
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
      
          MyClass myObject;
          myObject.performDistributedCalculation(2 , {1,2}, "HELLO, I am fine");
      
          return a.exec();
      }
      

      Any help on the same would be great !!

      Thanks in advance !!

      Regards,
      AROH

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 28 Mar 2024, 07:10 last edited by
      #2

      @AROH I guess you need to declare/register QVector<int>, see https://doc.qt.io/qt-6/custom-types.html

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      1/2

      28 Mar 2024, 07:05

      • Login

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