Geschrieben November 4, 2024 at 21:174. Nov 2024 Ich habe eine Klasse in Qt mit dem Creator erstellt. der Aufruf der Funktion "SetOnLCD128x64()" funktioniert problemlos. Beim Connect-Befehl klappt es leider nicht. cltf128x64* cl_lcd = new cltf128x64(); // cltf128x64 ist in separater Header und Sourcecode-Datei deklariert/definiert cl_lcd->SetOnLCD128x64(); // funktioniert connect(ui->pBuLCD2SetOn, &QPushButton::clicked, &cl_lcd, &cltf128x64::SetOnLCD128x64); // verursacht Fehler die Fehlermeldung: uwMainWindow.cpp:40:5: No matching member function for call to 'connect' qobject.h:200:36: candidate function not viable: no known conversion from 'void (QAbstractButton::*)(bool)' to 'const char *' for 2nd argument qobject.h:203:36: candidate function not viable: no known conversion from 'void (QAbstractButton::*)(bool)' to 'const QMetaMethod' for 2nd argument qobject.h:396:41: candidate function not viable: no known conversion from 'void (QAbstractButton::*)(bool)' to 'const char *' for 2nd argument qobject.h:221:9: candidate template ignored: substitution failure [with Func1 = void (QAbstractButton::*)(bool), Func2 = void (cltf128x64::*)()]: no type named 'ContextType' in 'QtPrivate::ContextTypeForFunctor<void (cltf128x64::*)()>' qobject.h:270:9: candidate function template not viable: requires 3 arguments, but 4 were provided Hat jemand eine Idee woran's hängt. Vielen Dank Uwe
Geschrieben November 5, 2024 at 08:105. Nov 2024 Hast du im Header die SetOnLCD128x64 Funktion in einem "public slots:" Anschnitt stehen?
Geschrieben November 5, 2024 at 09:165. Nov 2024 Autor Ja: /*! * @file cltf128x64.h * @brief Declaration of the LCD128x64-class WIT QObject * @date 2024-11-03 * @version 00 */ #ifndef CLTF128X64_H #define CLTF128X64_H #include "ip_connection.h" #include "bricklet_lcd_128x64.h" #include <QObject> //brauchen wir für "QT_BEGIN_NAMESPACE" #ifdef __cplusplus extern "C" { #endif /** * \defgroup cltf128x64 Klasse für TF-Steuerung */ /*! * \ingroup cltf128x64 * @brief Nothing special.\n */ #define UID_LCD128X64 "R3t" /*! * \ingroup cltf128x64 * @brief Nothing special.\n */ #define HOST "localhost" /*! * \ingroup cltf128x64 * @brief Nothing special.\n */ #define PORT 4223 QT_BEGIN_NAMESPACE namespace Ui { class cltf128x64; } QT_END_NAMESPACE class cltf128x64 { Q_OBJECT /******************************************************************************/ public: /*! * \ingroup cltf128x64 * .h: Constructor of the class "cltf128x64"\n * Nothing special.\n * @brief Constructor of the class "cltf128x64" */ cltf128x64(); /*! * \ingroup cltf128x64 * Destructor of the class "cltf128x64"\n * Nothing special.\n * @brief Destructor of the class "cltf128x64" */ ~cltf128x64(); public slots: /*! * \ingroup cltf128x64 * @brief function SetOnLCD128x64() * Initializes the LCD128x64 and register the callbacks * */ void SetOnLCD128x64(); /******************************************************************************/ private:
Geschrieben November 5, 2024 at 10:405. Nov 2024 connect(ui->pBuLCD2SetOn, &QPushButton::clicked, &cl_lcd, &cltf128x64::SetOnLCD128x64); Entferne da mal das & vor cl_lcd, weil das schon ein Pointer ist. Stattdessen brauchst du ggf. ein & vor ui->pBuLCD2SetOn, falls pBuLCD2SetOn kein Pointer ist.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.