Lambda problem with Qt5



  • 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?


Log in to reply
 

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