Hello community,
i have one class called mInterface(mInterface.cpp + mInterface.h) that reads data from udpSocket and then send those data to mupltiple(2) Forms(.ui) and mainwindow. i use Signals and slots communication to emit the data to all another forms.
normally, when i start my project i have to read datagram from udpsocket and then directly emit received data to Forms of my projects. Reading of datagram runs fine but the transfer of data to other forms doesn't works well. Only one Form receives transmitted data and the ather not. all classes Form are written in the same way but i don't understand why only one Form receives transmitted signal(data).
according to the signals/slots communication we can emit one signal to more slots from multiple objects or Form(.ui). if yes, why my project not works? somebody have an idea?
in advance, thank you for your help.

//mInterface.cpp class

Qt Code:
  1. #include "minterface.h"
  2.  
  3. mInterface::mInterface(QObject *parent) : QObject(parent)
  4. {
  5. readSocket = new QUdpSocket(this);
  6. readSocket->bind(QHostAddress::LocalHost, 50885);
  7. connect(readSocket, SIGNAL(readyRead()), this, SLOT(receiveData()));
  8. }
  9.  
  10. void mInterface::receiveData()
  11. {
  12. QByteArray rDatagram;
  13.  
  14. do
  15. {
  16. rDatagram.resize(int(readSocket->pendingDatagramSize()));
  17. readSocket->readDatagram(rDatagram.data(), rDatagram.size());
  18. } while(readSocket->hasPendingDatagrams());
  19.  
  20. QDataStream stream(&rDatagram, QIODevice::ReadOnly);
  21. stream.setVersion(QDataStream::Qt_5_9);
  22. memccpy(&arrChannels, (const void *)rDatagram.data(), sizeof(arrChannels), sizeof(arrChannels));
  23.  
  24. //int nombre = qrand()%(101);
  25. qDebug()<<"mInterface : "<<arrChannels[0].AC_Volt;
  26. emit dataAllChannels(arrChannels[0].AC_Volt);
  27.  
  28. }
To copy to clipboard, switch view to plain text mode 

form1.cpp
Qt Code:
  1. #include "readform.h"
  2. #include "ui_readform.h"
  3.  
  4. ReadForm::ReadForm(QWidget *parent) :
  5. QWidget(parent),
  6. ui(new Ui::ReadForm)
  7. {
  8. ui->setupUi(this);
  9. connect(&interface, SIGNAL(dataAllChannels(float)), this, SLOT(setReadData(float)));
  10. qDebug()<<"readform constructor";
  11. }
  12.  
  13. ReadForm::~ReadForm()
  14. {
  15. delete ui;
  16. }
  17.  
  18.  
  19. void ReadForm::setReadData(float d)
  20. {
  21.  
  22. qDebug()<<"readform : "<<d;
  23. ui->lcdNumber->display(d);
  24. }
  25.  
  26. void ReadForm::on_pushButton_clicked()
  27. {
  28. mform2.show();
  29. }
To copy to clipboard, switch view to plain text mode 

form2.cpp
Qt Code:
  1. #include "form2.h"
  2. #include "ui_form2.h"
  3.  
  4. Form2::Form2(QWidget *parent) :
  5. QWidget(parent),
  6. ui(new Ui::Form2)
  7. {
  8. ui->setupUi(this);
  9. connect(&form2, SIGNAL(dataAllChannels(float)), this, SLOT(meinSlot(float)));
  10. qDebug()<<"readform2 constructor";
  11. }
  12.  
  13. Form2::~Form2()
  14. {
  15. delete ui;
  16. }
  17.  
  18. void Form2::meinSlot(float f2)
  19. {
  20. ui->lcdNumber->display(f2);
  21. qDebug()<<"readform2 : "<< f2;
  22. }
To copy to clipboard, switch view to plain text mode 

//mainwindow.cpp

Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3.  
  4. MainWindow::MainWindow(QWidget *parent) :
  5. QMainWindow(parent),
  6. ui(new Ui::MainWindow)
  7. {
  8. ui->setupUi(this);
  9. connect(&m, SIGNAL(dataAllChannels(float)), this, SLOT(readAllValue(float)));
  10. qDebug()<<"Mainwindow constructor";
  11. }
  12.  
  13. MainWindow::~MainWindow()
  14. {
  15. delete ui;
  16. }
  17.  
  18. void MainWindow::readAllValue(float c)
  19. {
  20. qDebug()<<"Read Mainwindow : "<<c;
  21. ui->lcdNumber->display(c);
  22. }
  23.  
  24. void MainWindow::on_pushButton_clicked()
  25. {
  26. readform.show();
  27. }
To copy to clipboard, switch view to plain text mode 

//main.cpp

Qt Code:
  1. #include "mainwindow.h"
  2. #include <QApplication>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. QApplication a(argc, argv);
  7. MainWindow w;
  8. w.show();
  9.  
  10. return a.exec();
  11. }
To copy to clipboard, switch view to plain text mode