C++: Create a simple QT example to trigger a function in the main-thread by a signal from QThread
€8-30 EUR
Imekamilika
Imechapishwa about 6 years ago
€8-30 EUR
Kulipwa wakati wa kufikishwa
I need a simple QT example to trigger a function in the main-thread by a signal from QThread. Use the Signal/Slot principle.
As the base, just use in QT-Creator the standard QWidget application (QMainWindow).
1. start a new QThread.
2. in the QThread start a while(1) loop that should trigger every 3 seconds a funktion call in the MainThread.
3. The function in the MainThread is triggert by the trigger in the while(1) loop in the Qthread. This update the lable on [login to view URL]
int count = 0; // counted label updates
// The loop in the QThread:
while(1)
{
count++;
QThread::sleep(3);
// trigger the function in Main-Thread here !
}
// The function in the mainwindow-Thread(mainwindow):
ui→label→setText(count); // update the label
Thank you for looking, I look forward to hearing from you
Hi there,
We can help you.
This is quite a simple assignment. We have been working with Qt for more than 5 years.
Looking forward to working with you.
Thanks and best regards,