After opening the processing image button in qt, the wait application is processed in a loop

After opening the processing image button in qt, read the image in a loop and process the wait application

Use while (1) to read and process the image in a loop. The label in qt will not respond when the image is displayed. At this time, add a waiting function, even if you wait for 0 seconds, the label will display the image

Create a new class function (xxxxx.cpp file)

#include
#include

void Camera::Wait(int msec)
{
QTime reachTime = QTime::currentTime().addMSecs(msec);
while( QTime::currentTime() < reachTime )
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);;
}

The header file corresponding to the new class function (xxxxx.h file):
void Wait(int msec);

In the button response function header file (.h file):

#include “xxxxx.h” //xxxxx is the name of the new class function
Camera *m_pCamera;

In the button response function:

m_pCamera->Wait(10000)//Wait for 10 seconds after the program runs here, and then continue to execute

With while(1), the program can re-read, detect, and output after 10 seconds of reading, detecting, and outputting the image to achieve continuous detection

Guess you like

Origin blog.csdn.net/qq_43207709/article/details/112545489