Jump to content

Recommended Posts

Posted

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

Posted

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:

Posted
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...