Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Transmit QString into lambda
Forum Updated to NodeBB v4.3 + New Features

Transmit QString into lambda

Scheduled Pinned Locked Moved Solved C++ Gurus
3 Posts 2 Posters 870 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.
  • sonichyS Offline
    sonichyS Offline
    sonichy
    wrote on last edited by
    #1

    Transmit QString into lambda error:

    QString s = "";
    QStringList SL_package;
    connect(process, &QProcess::readyReadStandardOutput, [=]{
        QString so = QString(process->readAllStandardOutput());
        s = s + so;    // no viable overloaded '='
    });
    connect(process, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), [=]{
        s = s.replace("package:", "");    // no matching member function for call to 'replace'
        SL_package = s.split("\n");
        SL_package.removeAll("");
        showPackage("");
    });
    

    https://github.com/sonichy

    jsulmJ 1 Reply Last reply
    0
    • sonichyS sonichy

      Transmit QString into lambda error:

      QString s = "";
      QStringList SL_package;
      connect(process, &QProcess::readyReadStandardOutput, [=]{
          QString so = QString(process->readAllStandardOutput());
          s = s + so;    // no viable overloaded '='
      });
      connect(process, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), [=]{
          s = s.replace("package:", "");    // no matching member function for call to 'replace'
          SL_package = s.split("\n");
          SL_package.removeAll("");
          showPackage("");
      });
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @sonichy If you want to change s in lambda then you have to capture it as reference.
      Also you should read the whole compiler error, because it tells you what the problem is...

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

      sonichyS 1 Reply Last reply
      2
      • jsulmJ jsulm

        @sonichy If you want to change s in lambda then you have to capture it as reference.
        Also you should read the whole compiler error, because it tells you what the problem is...

        sonichyS Offline
        sonichyS Offline
        sonichy
        wrote on last edited by
        #3

        @jsulm Change [=] to [=, &s]

        https://github.com/sonichy

        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