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

Lambda function in QT

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 740 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 14 Mar 2018, 13:25 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

    A 1 Reply Last reply 14 Mar 2018, 13:50
    0
    • D dhu0504
      14 Mar 2018, 13:25

      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

      A Offline
      A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on 14 Mar 2018, 13:50 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

      1/2

      14 Mar 2018, 13:25

      • 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