2013-10-04 38 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以開始濺射屏幕的定時器。