uwew Geschrieben November 4, 2024 at 21:17 Share Geschrieben November 4, 2024 at 21:17 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 Zitieren Link zu diesem Kommentar Share on other sites More sharing options...
photron Geschrieben November 5, 2024 at 08:10 Share Geschrieben November 5, 2024 at 08:10 Hast du im Header die SetOnLCD128x64 Funktion in einem "public slots:" Anschnitt stehen? Zitieren Link zu diesem Kommentar Share on other sites More sharing options...
uwew Geschrieben November 5, 2024 at 09:16 Autor Share Geschrieben November 5, 2024 at 09:16 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: Zitieren Link zu diesem Kommentar Share on other sites More sharing options...
MatzeTF Geschrieben November 5, 2024 at 10:40 Share Geschrieben November 5, 2024 at 10:40 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. Zitieren Link zu diesem Kommentar Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.