2012-08-22 50 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 
}