Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. expected body of lambda expression
QtWS25 Last Chance

expected body of lambda expression

Scheduled Pinned Locked Moved Solved QML and Qt Quick
linuxlambdaqmlgccg++
4 Posts 2 Posters 4.9k 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.
  • T Offline
    T Offline
    tansgumus
    wrote on 28 Apr 2019, 09:02 last edited by tansgumus
    #1

    Hi,

    I'm working in integrating QML and C++ by applying this example but the parser says (unable to build the project too):

    error: expected body of lambda expression // points to  emit [ emit]  userNameChanged();
    

    Although I already included CONFIG += c++11 in my .pro file!

    How can I fix this issue?

    • OS: Linux Mint 19.1 xfce
    • GCC: gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
    • G++: g++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 28 Apr 2019, 09:05 last edited by
      #2

      Hi
      Can you show the actual code that gives this error?
      Looking at sample

      void BackEnd::setUserName(const QString &userName)
      {
          if (userName == m_userName)
              return;
      
          m_userName = userName;
          emit userNameChanged();
      }
      

      I see no lambdas or any cause for such error.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tansgumus
        wrote on 28 Apr 2019, 09:08 last edited by
        #3

        silly me. I was playing with lambda so I forgot to remove the code.

        M 1 Reply Last reply 28 Apr 2019, 09:09
        1
        • T tansgumus
          28 Apr 2019, 09:08

          silly me. I was playing with lambda so I forgot to remove the code.

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 28 Apr 2019, 09:09 last edited by
          #4

          @tansgumus
          ah, so the [] part was left and
          it missed the actual body ? ( {})
          Well these things happens :)

          1 Reply Last reply
          0

          2/4

          28 Apr 2019, 09:05

          • Login

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