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
Forum Updated to NodeBB v4.3 + New Features

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 4.7k 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
    20 Jan 2023, 13:31

    @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

    J Offline
    J Offline
    JonB
    wrote on 20 Jan 2023, 13:35 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 20 Jan 2023, 13:44
    1
    • J JonB
      20 Jan 2023, 13:35

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

      D Offline
      D Offline
      Dean21
      wrote on 20 Jan 2023, 13:44 last edited by
      #22

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

      1 Reply Last reply
      0
      • J jsulm
        20 Jan 2023, 13:34

        @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 20 Jan 2023, 13:56 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

        J 1 Reply Last reply 23 Jan 2023, 06:17
        0
        • D Dean21
          20 Jan 2023, 13:56

          @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

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 23 Jan 2023, 06:17 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

          21/24

          20 Jan 2023, 13:35

          • Login

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