Hi there guys, I am new to C++11 expressions. I got a lambda below and it crashes my program.
Qt Code:
  1. void Joburg_Page::connect_to_HTML_tags(bool ok)
  2. {
  3. QString docTitle;
  4.  
  5. this->runJavaScript("document.title"
  6. "}", [&docTitle](const QVariant &data){docTitle = data.toString();});
  7.  
  8. qDebug() << docTitle <<endl;
  9. }
  10. }
To copy to clipboard, switch view to plain text mode 

Why is it necessary that I must declare docTitle is a member of the class before the above code works?