Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved Lambda function in QT

    General and Desktop
    2
    2
    620
    Loading More Posts
    • 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.
    • D
      dhu0504 last edited by

      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

      aha_1980 1 Reply Last reply Reply Quote 0
      • aha_1980
        aha_1980 Lifetime Qt Champion @dhu0504 last edited by aha_1980

        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.

        Qt has to stay free or it will die.

        1 Reply Last reply Reply Quote 8
        • First post
          Last post