Important: Please read the Qt Code of Conduct -

Signals and Slot Problem

  • in socketudp.cpp
    ipDataReceived(datagram) is emitted

    In main.cpp
    socketudp UnderUDP;
    UnderUDP object created.
    If i create object in mainwindow.cpp, UDP data cannot received (TCP no problem)
    (strange problem, i tried debugging many times and this is the symptom.

    in mainwindow.cpp

    doing debug, i found my SLOT is never call. Why is this so?
    I did experiment 2.
    I move slot and QObject::connect to main.cpp but can't declare slot in main.cpp. Pls Help ..
    I am out of idea.

  • Lifetime Qt Champion


    Without any code it's pretty much Crystal Ball (™).

    IRCC, debugging, so can you share it ?

  • I found that i can make connection for UDP to my system not in Mainwindow but in main (before mainwindow object is created), but my problem is main do not have header file ( there is no main.h only main.cpp).

    Thus i can't add a SLOT in main.h.

  • Lifetime Qt Champion

    Depends, you can use C++11 lambda as slots

Log in to reply