级联信号不起作用

时间:2013-07-13 10:40:23

标签: c++ qt qml blackberry-cascades

我在我的QML文件中声明了一张工作表,其中包含ID" splashscreen"

当我的应用程序执行计算密集型任务时,我会发出working()信号。

我将此代码附加到我的QML文件的主要元素:

onCreationCompleted: {
    _encryptedattachment.finished.connect(splashscreen.close);
    _encryptedattachment.working.connect(splashscreen.open);
    console.log("connected");
}

如果我通过调用需要解密的文件来打开应用程序,

    _encryptedattachment.working.connect(splashscreen.open);

无法打开启动画面,即使事件被触发(我在调试器中检查了代码

emit working()

已执行。

编辑:

我将onCreated代码更改为:

onCreationCompleted: {
    splashscreen.open();
    _encryptedattachment.working.connect(showSplash);
    _encryptedattachment.finished.connect(hideSplash);
    console.log("connected");
}
function showSplash() {
    console.log("open splashscreen");
    splashscreen.open();
}
function hideSplash() {
    console.log("close splashscreen");
    splashscreen.close();
}

并且这两个日志都出现在控制台中。

1 个答案:

答案 0 :(得分:1)

致电QSplashScreen::show()后,您必须致电QApplication::processEvents(),以便eventloop在屏幕上绘制它。请务必在每次启动更新后调用QApplication::processEvents()