Lambda function in QT



  • I am having one member function in the class.

    In the same class i am using the below code to interact the aws.

    client.connect(&client, &QAwsIoTClient::messageReceived,
    [&value](const QString &topicName, const QByteArray &message){
    //need to call member function
    });

    Now i want to call the member function in the above code.

    It will be very helpful any one give some solution for this

    Thanks in advance


  • Qt Champions 2017

    Hi @dhu0504 said in Lambda function in QT:

    client.connect(&client, &QAwsIoTClient::messageReceived,
    [&value](const QString &topicName, const QByteArray &message){
    //need to call member function
    });

    You need to capture this to be able to call member functions:

    client.connect(&client, &QAwsIoTClient::messageReceived,
                   [this, &value](const QString &topicName, 
                                  const QByteArray &message) {
       //need to call member function
    });
    

    After that it should work nicely.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.