[英]Display a QMessageBox from a QThread
我想從一個單獨的線程顯示一個消息框,但是,我收到此錯誤:
QThread: Destroyed while thread is still running
誰能解釋如何從線程中顯示消息框?
發出信號。 由於您無法在Qthread
執行UI內容,而是將您的消息作為信號的參數發送。
你的qthread中的信號decalaration:
signals:
void write2SysStatus(QString theMessage);
從qthread發出信號:
emit write2SysStatus("Some status");
QMainWindow中的槽聲明/定義:
public slots:
void eWriteLine ( QString theMessage ){
//this is where you use you message box.
}
連接插槽和信號:
connect(pFPSengine, SIGNAL(write2SysStatus(QString)), this,SLOT(eWriteLine(QString)));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.