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. Lambda problem with Qt5
Qt 6.11 is out! See what's new in the release blog

Lambda problem with Qt5

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.1k 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.
  • M Offline
    M Offline
    matthewpl
    wrote on last edited by
    #1

    Hi, today I tried do something like this:

    @connect(lambdaButton, &QPushButton::clicked, {});@

    and I get this compile error:

    @In file included from ../../../../lib/qt5/qtbase/include/QtCore/qobjectdefs_impl.h:1:0,
    from ../../../../lib/qt5/qtbase/include/QtCore/../../src/corelib/kernel/qobjectdefs.h:47,
    from ../../../../lib/qt5/qtbase/include/QtCore/qobjectdefs.h:1,
    from ../../../../lib/qt5/qtbase/include/QtCore/../../src/corelib/kernel/qmetatype.h:51,
    from ../../../../lib/qt5/qtbase/include/QtCore/qmetatype.h:1,
    from ../../../../lib/qt5/qtbase/include/QtCore/../../src/corelib/kernel/qvariant.h:48,
    from ../../../../lib/qt5/qtbase/include/QtCore/qvariant.h:1,
    from ../../../../lib/qt5/qtbase/include/QtCore/QVariant:1,
    from ./ui_widget.h:13,
    from ../../../../src/kurs-qt/qt11/widget.hpp:4,
    from ../../../../src/kurs-qt/qt11/widget.cpp:1:
    ../../../../lib/qt5/qtbase/include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h: In instantiation of 'static void QtPrivate::FunctorCall<QtPrivate::IndexesList<I ...>, QtPrivate::List<SignalArgs ...>, R, Function>::call(Function, void**) [with int ...I = {0}; SignalArgs = {bool}; R = void; Function = Widget::Widget(QWidget*)::<lambda()>]':
    ../../../../lib/qt5/qtbase/include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:434:13: required from 'static void QtPrivate::Functor<Function, N>::call(Function&, void*, void**) [with SignalArgs = QtPrivate::List<bool>; R = void; Function = Widget::Widget(QWidget*)::<lambda()>; int N = 1]'
    ../../../../lib/qt5/qtbase/include/QtCore/../../src/corelib/kernel/qobject.h:440:13: required from 'void QObject::QFunctorSlotObject<Func, N, Args, R>::call(QObject*, void**) [with Func = Widget::Widget(QWidget*)::<lambda()>; int N = 1; Args = QtPrivate::List<bool>; R = void; QObject = QObject]'
    ../../../../src/kurs-qt/qt11/widget.cpp:41:1: required from here
    ../../../../lib/qt5/qtbase/include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:395:13: error: no match for call to '(Widget::Widget(QWidget*)::<lambda()>) (QtPrivate::RemoveRef<bool>::Type&)'
    ../../../../src/kurs-qt/qt11/widget.cpp:9:48: note: candidates are:
    In file included from ../../../../lib/qt5/qtbase/include/QtCore/qobjectdefs_impl.h:1:0,
    from ../../../../lib/qt5/qtbase/include/QtCore/../../src/corelib/kernel/qobjectdefs.h:47,
    from ../../../../lib/qt5/qtbase/include/QtCore/qobjectdefs.h:1,
    from ../../../../lib/qt5/qtbase/include/QtCore/../../src/corelib/kernel/qmetatype.h:51,
    from ../../../../lib/qt5/qtbase/include/QtCore/qmetatype.h:1,
    from ../../../../lib/qt5/qtbase/include/QtCore/../../src/corelib/kernel/qvariant.h:48,
    from ../../../../lib/qt5/qtbase/include/QtCore/qvariant.h:1,
    from ../../../../lib/qt5/qtbase/include/QtCore/QVariant:1,
    from ./ui_widget.h:13,
    from ../../../../src/kurs-qt/qt11/widget.hpp:4,
    from ../../../../src/kurs-qt/qt11/widget.cpp:1:
    ../../../../lib/qt5/qtbase/include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:395:13: note: void ()() <conversion>
    ../../../../lib/qt5/qtbase/include/QtCore/../../src/corelib/kernel/qobjectdefs_impl.h:395:13: note: candidate expects 1 argument, 2 provided
    ../../../../src/kurs-qt/qt11/widget.cpp:9:50: note: Widget::Widget(QWidget
    )::<lambda()>
    ../../../../src/kurs-qt/qt11/widget.cpp:9:50: note: candidate expects 0 arguments, 1 provided@

    But when I do this:

    @connect(this, &Widget::testSignal, {});@

    everything work just fine.

    Where I did mistake or what I don't know about using Lambda in Qt projects?

    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