作者:
checkIO (chec)
2017-05-25 15:51:12開發平台(Platform): (Ex: Win10, Linux, ...)
win10
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
vs2015
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
qt5.7
問題(Question):
void PC_info::setupTimer(){
timer = new QTimer(0);
connect(timer,SIGNAL(timeout(),this,SLOT(OnScan()),Qt::DirectConnection));
timer->start(1000);
//thread = new QThread(this);
//timer ->moveToThread(thread);
//thread->start();
}
大家好 目前在寫定時掃電腦資訊的程式
OnScan是去掃HWinfo關於電腦的資訊
但是進到OnScan的時候 會讓整個ui出現頓感
後來使用QThread來寫的時候 頓感解決
但....會有機率性的讓ui整個凍結
不知道是不是thread的用法錯誤了呢
作者:
uranusjr (â†é€™äººæ˜¯è¶…級笨蛋)
2017-05-25 17:21:00其實重點應該是 onscan 要放到 thread 裡, 看上面的程式好像只有 timer 本身在背景執行, 這樣應該沒用把 onscan 放到自己的 class 裡, 在 PC_info 初始化後moveToThread, 然後 connect 這樣比較合理