QT5.8线程使用主界面控件,要使主界面相关控件在线程里面运行并对控件进行操作(),求解
在下铧茗哥 2019-08-06 02:09:27 使用graphicsView控件显示图片,但是无法通过线程操作改函数显示图片,老是报错,用槽函数的办法显示视频延迟太高 ,帧数一高就挂掉。
我需要的是在线程while中直接修改界面控件的图片。
附槽函数操作代码:
#include "MyThread.h"
#include <QDebug>
#include <QMutex>
#include <QThread>
MyThread::MyThread(MainWindow *ui)
{
this->win = ui;
connect(this, SIGNAL(bar_sig()), this, SLOT(bar_slot()));
isStop = false;
}
MyThread::~MyThread()
{
}
void MyThread::closeThread()
{
isStop = true;
}
void MyThread::pauses()
{
this->pause.lock();
}
void MyThread::resume()
{
this->pause.unlock();
}
void MyThread::run()
{
while (true)
{
pause.lock();
emit bar_sig();
if (isStop)
return;
msleep(420);
pause.unlock();
}
}
void MyThread::bar_slot() {
win->Videorun();
//在槽函数中调用MainWindow类的控件操作函数
}
望各位大佬告知怎么操作。。。。。。