2012-08-22 56 views
0

我使用類QML和多線程的QThread

class DesktopFileScanner : public QThread 
{ 
void scan() { start(QThread::HighPriority)); } 
void run() { /* the scanning instructions here*/} 
/**/ 
}; 

執行耗時(〜2秒)操作。我想在掃描儀正在執行時顯示繁忙的指示符。繁忙的指標被稱爲

ind 

的QML表具有這個屬性:

Component.onCompleted: 
{ 
    scanner.scan() // scanner is an instance of DesktopFileScanner 
    ind.visible = false 
} 

這樣掃描儀完成掃描前的指示燈變爲不可見。 如何解決它,這樣掃描儀線程完成後

ind.visible = false 

將被調用(掃描儀完成掃描)提前

感謝

在QML

回答

1

連接的項目可以用來

Component.onCompleted: 
{ 
    scanner.scan() 
} 

Connections 
{ 
    target: scanner 
    onFinished: ind.visible = false 
}