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. Lambda function in QT
Qt 6.11 is out! See what's new in the release blog

Lambda function in QT

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 876 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.
  • D Offline
    D Offline
    dhu0504
    wrote on last edited by
    #1

    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_1980A 1 Reply Last reply
    0
    • D dhu0504

      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_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by aha_1980
      #2

      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
      8

      • Login

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