expected body of lambda expression

  • 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

  • Lifetime Qt Champion

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

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

    I see no lambdas or any cause for such error.

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

  • Lifetime Qt Champion

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


Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.