Beckhoff Ads C++ Notification Callback - Qt Widget Label aktualisieren

zwuebbl

Level-1
Beiträge
11
Reaktionspunkte
0
Zuviel Werbung?
-> Hier kostenlos registrieren
Sehr geehrte Damen und Herren,
ich möchte über die Callback Funktion, welche bei Wertänderung durchlaufen wird ein Qt Widget Label Text aktualisieren.
Leider schlugen bis jetzt alle versuche fehl. Ich hänge mal den Header und Source Code an.

Idee war, da Qt, statt einem delegate wie in C#, Signal und Slot zu verwenden.
connect(this, SIGNAL(&callback(AdsNotificationHeader*)), this->labelNotification, SLOT(UpdateUi(AdsNotificationHeader*)));

Bitte um mithilfe.

Mfg Marcel
 

Anhänge

Zuviel Werbung?
-> Hier kostenlos registrieren
Leider nicht. Das habe ich schon getestet und funktioniert auch. Das Problem ist die Kommunikation vom Notification zu den Benutzersteuerelementen der Gui.

Hier wäre das Kernproblem:

MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
labelNotification = new QLabel(this);

//connect(this, SIGNAL(clicked()), this, SLOT(click()));

CreateAdsNotification();


connect(this, SIGNAL(&callback(AdsNotificationHeader*)), this->labelNotification, SLOT(UpdateUi(AdsNotificationHeader*)));
}

// Callback-function
void __stdcall MainWindow::Callback(AmsAddr* pAddr, AdsNotificationHeader* pNotification, ulong hUser)
{
int nIndex;
static ulong nCount = 0;


qDebug() << ++nCount << ". Call:\n";

// print (to screen)) the value of the variable
qDebug() << "Value: " << *(ulong *)pNotification->data << '\n';
qDebug() << "Notification: " << pNotification->hNotification << '\n';

emit UpdateUi(pNotification); // Signal senden

//labelNotification->setText("Test");


// Größe des Buffers in Byte
qDebug() << "SampleSize: " << pNotification->cbSampleSize << '\n';

// 32-Bit Variable (auch Zeiger), die beim AddNotification gesetzt wurde // (siehe main)
qDebug() << "hUser: " << hUser << '\n';

// Print out the ADS-address of the sender
qDebug()<< "ServerNetId: ";
for (nIndex = 0; nIndex < 6; nIndex++)
qDebug() << (int)pAddr->netId.b[nIndex] << ".";
qDebug() << "\nPort: " << pAddr->port << "\n\n";
//cout.flush();
}

void MainWindow::UpdateUi(AdsNotificationHeader* pNotification)
{
qDebug() << "Aufgerufen";

//labelNotification->setText(QString::number(*(ulong *)pNotification->data));
}
 
Zuletzt bearbeitet:
Zurück
Oben