C:\Users\48318\Desktop\Qt\2048\interface_44.cpp:35: error: static assertion failed: Signal and slot arguments are not compatible. In file included from C:\Qt\5.15.2\mingw81_64\include/QtGui/qtguiglobal.h:43, from C:\Qt\5.15.2\mingw81_64\include/QtWidgets/qtwidgetsglobal.h:43, from C:\Qt\5.15.2\mingw81_64\include\QtWidgets/qmainwindow.h:43, from C:\Qt\5.15.2\mingw81_64\include\QtWidgets/QMainWindow:1, from ..\2048\interface_44.h:4, from ..\2048\interface_44.cpp:1: C:\Qt\5.15.2\mingw81_64\include/QtCore/qobject.h: In instantiation of 'static QMetaObject::Connection QObject::connect(const typename QtPrivate::FunctionPointer<Func>::Object*, Func1, const typename QtPrivate::FunctionPointer<Func2>::Object*, Func2, Qt::ConnectionType) [with Func1 = void (QTimer::*)(QTimer::QPrivateSignal); Func2 = void (Interface_44::*)(QTimerEvent*); typename QtPrivate::FunctionPointer<Func>::Object = QTimer; typename QtPrivate::FunctionPointer<Func2>::Object = Interface_44]': ..\2048\interface_44.cpp:35:69: required from here C:\Qt\5.15.2\mingw81_64\include/QtCore/qglobal.h:121:63: error: static assertion failed: Signal and slot arguments are not compatible. # define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message) ^~~~~~~~~~~~~~~ C:\Qt\5.15.2\mingw81_64\include/QtCore/qobject.h:255:9: note: in expansion of macro 'Q_STATIC_ASSERT_X' Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value), ^~~~~~~~~~~~~~~~~
时间: 2024-03-11 10:50:45 浏览: 132
JAVA OpenCV Error: Assertion failed (!empty()) in cv::CascadeClassifier::detectMultiScale….
这个错误通常是由于信号和槽之间的参数不匹配导致的。请确保你的信号和槽的参数类型和数量都是匹配的。在这种情况下,错误信息指出 `Signal and slot arguments are not compatible.`,因此你需要检查你的信号和槽的参数类型是否匹配。
同时,你在连接信号和槽时,需要传递指向成员函数的指针,而不是直接传递成员函数名。例如:
```c++
connect(timer, &QTimer::timeout, this, &YourClass::timerEvent);
```
其中,`&YourClass::timerEvent` 是指向 `YourClass` 类中的 `timerEvent()` 成员函数的指针。请确保你的信号和槽的参数类型匹配,并正确地传递指向成员函数的指针。
阅读全文