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. how to use Qtconcurrent::run with either a member function or maybe a lamdba function

how to use Qtconcurrent::run with either a member function or maybe a lamdba function

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtconcurrentthreadfunctionc++qfuture
24 Posts 5 Posters 3.5k 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 Dean21

    @jsulm said in how to use Qtconcurrent::run with either a member function or maybe a lamdba function:

    connect(&client, &QMMqttClient::onConnected, this, this{ // Use client here

    Hi jsulm, thanks for your help, but that didnt work, the error message was

    client' is not captured 
    

    and it the error says the error is on the client.subscribeTopic("command/stop") ; line

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by
    #21

    @Dean21
    Let's start with: did you actually delete the QMMqttClient client; statement in the constructor?

    D 1 Reply Last reply
    1
    • JonBJ JonB

      @Dean21
      Let's start with: did you actually delete the QMMqttClient client; statement in the constructor?

      D Offline
      D Offline
      Dean21
      wrote on last edited by
      #22

      @JonB yes sorry I forgot to uncomment this i think this is working now

      1 Reply Last reply
      0
      • jsulmJ jsulm

        @Dean21 Please show your current code.
        This code works for me just fine (ui is member of the class calling connect):

        connect(ui->pushButton, &QPushButton::pressed, [this]() { ui->pushButton->setText("DONE"); });
        
        D Offline
        D Offline
        Dean21
        wrote on last edited by
        #23

        @jsulm sorry i forgot to comment a line of code, this is working now thank you so much for your help I was really stuck and dont think I would have fixed without help from everyone here thank you.
        But would this prevent any functionality of any other code from working, for example I have a lineEdit box and once I enter a value its suppose to show in another lineEdit box but that functionality seems to have stopped working, since this new part started working

        jsulmJ 1 Reply Last reply
        0
        • D Dean21

          @jsulm sorry i forgot to comment a line of code, this is working now thank you so much for your help I was really stuck and dont think I would have fixed without help from everyone here thank you.
          But would this prevent any functionality of any other code from working, for example I have a lineEdit box and once I enter a value its suppose to show in another lineEdit box but that functionality seems to have stopped working, since this new part started working

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #24

          @Dean21 Please show your current code if something does not work...

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

          1 Reply Last reply
          0

          • Login

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