Difference Between QMetaObject::invokeMethod and Connect()

Viewed 136

my app contain a lot of labels in The mainWindow Thread which updated via connect(SIGNAL(),SLOT()) from a udp thread (one way connection from udp to mainwindow "udp recive send data to main window to update" ) , at first the app is crashing because to much data send from udp thread to MainWindow(main thread) , i added timer in udp thread to emit update every 250ms and works ,but is slow and freezes for small time when the user make some interaction like touch on app .

so i found another method to update GUI From Thread QMetaObject::invokeMethod

QMetaObject::invokeMethod(label, SLOT(setText(const QString &)), Q_ARG(QString, "Hello"));

what the difference between 2 ways ? is invoke Method not block main thread ? and completely done in the udp thread ? i can use invoke Method to update ui with the same speed of udp thread recive data without blocking mainwindow (main thread)? if not is there away to do that ?

thank you for help ,

0 Answers
Related