2013-10-04 36 views
0

那么,从android转移到黑莓级联qml编码。黑莓qml级联2秒开机画面

我想在qml中手动添加启动画面,时间限制为2-3秒。

我该如何做到这一点,因为在qml中没有与时间相关的选项。

在网上搜索和开发者论坛没有透露这种情况。

帮助!帮帮我!帮帮我!

这是我main.qml

import bb.cascades 1.0 
import bb.myTimer 1.0 //error unknown library bb.myTimer 


Page 
{ 
Container { 
    layout: DockLayout { 
    } 
    onCreationCompleted: { 
     myTimer.start(); 
    } 

    ImageView { 
     id: mImageViewIcon 
     horizontalAlignment: HorizontalAlignment.Fill 
     verticalAlignment: VerticalAlignment.Fill 
     imageSource: "asset:///splash1.png" 
    } 

    attachedObjects: [ 
     QTimer {  //error : The QTimer component might be an unknown or custom  component. Its properties are not validated. 
      id: myTimer 
      interval: 3000 
      onTimeout: { 
       //Push New Page here 

       mysheet1.open(); 


      } 
     }, 

     Sheet 
     { 
      id: mysheet1 
      peekEnabled: false 
      Page 
      { 
       Container 
       { 
        background: Color.Transparent 


        ImageView 
        { 
         horizontalAlignment: HorizontalAlignment.Fill 
         verticalAlignment: VerticalAlignment.Fill 
         imageSource: "asset:///splash2.png" 
        } 


      } 
     } 
     }  
    ] 
    } 
} 

我的main.cpp

#include <bb/cascades/Application> 

#include <QLocale> 
#include <QTranslator> 

**#include <Qtimer>** 

#include "applicationui.hpp" 

#include <Qt/qdeclarativedebug.h> 

using namespace bb::cascades; 

Q_DECL_EXPORT int main(int argc, char **argv) 
{ 
Application app(argc, argv); 

**qmlRegisterType<QTimer>("my.timer", 1, 0, "QTimer");** 

// Create the Application UI object, this is where the main.qml file 
// is loaded and the application scene is set. 
new ApplicationUI(&app); 

// Enter the application main event loop. 
return Application::exec(); 
} 

在此先感谢。

+0

你需要导入定时器为“import my.timer 1.0”,而不是“import bb.myTimer 1.0” – Kunal

+0

你可以在这里找到更多的细节“http://kunalmaemo.blogspot。kr/2012/12/using-timer-with-bb10-cascade-qml-code.html“ – Kunal

回答

2

有选项飞溅bar-descriptor.xml

打开bar-descriptor.xml >>选择标签"Application"

You can see Splash Screens: box at right side. Select your splash screen.

如果你想手动然后按照下面的代码。

在第&页中使用启动画面作为imageview使用Timer。 定时器超时时推送新页面。

以下是Timer的示例代码。

import bb.cascades 1.0 
import my.timer 1.0 
Page { 
    Container { 
     layout: DockLayout { 
     } 
     onCreationCompleted: { 
      mTimer.start(); 
     } 
     ImageView { 
      id: mImageViewIcon 
      horizontalAlignment: HorizontalAlignment.Fill 
      verticalAlignment: VerticalAlignment.Fill 
      imageSource: "asset:///images/splash.png" 
     } 
     attachedObjects: [ 
      QTimer { 
       id: mTimer 
       interval: 2000 
       onTimeout: { 
        //Push New Page here 
       } 
      } 
     ] 
    } 
} 

不要忘了添加下面一行在main.cpp中

qmlRegisterType<QTimer>("my.timer", 1, 0, "QTimer"); 
+0

你告诉abour bar描述符文件的东西,我知道它的缺点是我们只能添加1个图像作为启动画面,运行它显示几乎不到一秒或一秒钟。我的老板他希望我一个接一个地保持2个启动画面,并希望它们每个至少等待3秒。ufff ...你是否认为上述代码可以工作吗?因为我在黑莓officail文档中看到并阅读了我们需要创建timer.hpp头文件和timer.cpp文件的一些代码来使用QTimer。这里是链接,请检查一次 –

+0

链接:http: //developer.blackberry.com/native/documentation/cascades/dev/signals_slots/signals_slots_create_ui.html –

+0

请更新我的评论和链接 –

1

于我的答案的时候,Momentics的是2.0版本。在这个版本的Momentics中,启动画面不需要QML。

要将闪屏添加到您的应用程序,请打开bar-descriptor.xml文件。在右侧的图标规格下方,选择要用作闪屏图像的图像。

就是这样。

重新生成并运行,并享受

0

尝试使用动画作为TranslateTransition和设置时间等待第二。

代码:

attachedObjects: [ 
TranslateTransition { 
    id: splashScreen 
    duration: 2000 //wait in milliseconds 
    onEnded: { 
     //here the code to close splash screen   
    } 
}] 

并使用splashScreen.play(); //add this in onCreationComplete()一个对象作为容器或ImageView的,不PageNavigationPane以开始溅射屏幕的定时器。