当前位置: 代码迷 >> QT开发 >> QT中多线程传递参数有关问题
  详细解决方案

QT中多线程传递参数有关问题

热度:84   发布时间:2016-04-25 03:14:58.0
QT中多线程传递参数问题
主线程中有两个变量QPushButton *btn,QLabel *lab想通过自定义线程的构造函数传递次线程。
请问我的构造函数应该怎么写,我在dialog中怎么调用构造函数传递参数。
------解决方案--------------------
你的次线程构造函数:
class YourSencondThread: public QThread
{
public:
  explicit YourSencondThreadQPushButton *btn,QLabel *lab, QObject *parent = 0);//构造函数有默认值的要放后面
}

dialog中 :
YourSencondThread *thread  = new YourSencondThread(button, label);
thread->start();//启动
  相关解决方案