我想做一个非常耗时的操作,当按下QT按钮但失败时,有人能帮我解释一下吗?谢谢!代码是:
bool eventFilter(QObject *target, QEvent *event)
{
if (target == ui.zoominBtn){
if (event->type() == QEvent::MouseButtonPress){
phcs[curPhcId].zoom(0.1);
renderRaytracingImage();
}
}
return QMainWindow::eventFilter(target, event);
}现在我将耗时的部分转移到QThread:
if (target == ui.zoominBtn){
if (event->type() == QEvent::MouseButtonPress){
//phcs[curPhcId].zoom(0.1);
TracerayThread *traceThread = new TracerayThread(&scene,&(phcs[curPhcId]),this);
connect(traceThread, SIGNAL(resultReady()), this, SLOT(render()));
connect(traceThread, SIGNAL(finished()), traceThread, SLOT(deleteLater()));
traceThread->start();
}
}我需要传递两个指向新线程的指针,我可以这样做吗?
发布于 2017-07-09 16:21:17
你可以使用QPushButton点击信号。
connect(YourButtonName, &QPushButton::clicked, this, &MainWindow::YourSlotName);不需要使用eventFilter。如果你想使用它,别忘了installEventFilter
https://stackoverflow.com/questions/44994288
复制相似问题