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. Catch signal with lambda expression

Catch signal with lambda expression

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 300 Views 1 Watching
  • 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.
  • S Offline
    S Offline
    Stephan Lorenzen
    wrote on last edited by Stephan Lorenzen
    #1

    Hi guys,
    Why does that work

    QPushButton *butOK = new QPushButton("OK");
    connect(butOK, &QPushButton::clicked, [=]()  { ... });
    

    But this

    QSpinBox *spinMin = new QSpinBox();
    connect(spinMin, &QSpinBox::valueChanged, [=]() {butOK->setEnabled(true);});
    

    does not work?? The compiler complains
    "No matching function for call to connect(QSpinBox*&, <unresolved overloaded function type>, function()::<lambda(QVariant)>::lambda()>)" ,
    but that sounds very cryptic to me.
    Is it possible to catch QSpinBox::valueChanged with a lambda?

    ODБOïO 1 Reply Last reply
    0
    • S Stephan Lorenzen

      Hi guys,
      Why does that work

      QPushButton *butOK = new QPushButton("OK");
      connect(butOK, &QPushButton::clicked, [=]()  { ... });
      

      But this

      QSpinBox *spinMin = new QSpinBox();
      connect(spinMin, &QSpinBox::valueChanged, [=]() {butOK->setEnabled(true);});
      

      does not work?? The compiler complains
      "No matching function for call to connect(QSpinBox*&, <unresolved overloaded function type>, function()::<lambda(QVariant)>::lambda()>)" ,
      but that sounds very cryptic to me.
      Is it possible to catch QSpinBox::valueChanged with a lambda?

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      @Stephan-Lorenzen
      https://doc.qt.io/qt-5/qspinbox.html#valueChanged

      1 Reply Last reply
      4
      • S Offline
        S Offline
        Stephan Lorenzen
        wrote on last edited by
        #3

        Great!! It works!! Thanks a lot

        Christian EhrlicherC 1 Reply Last reply
        0
        • S Stephan Lorenzen

          Great!! It works!! Thanks a lot

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Stephan-Lorenzen Please mark the topic as solved then.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          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