标签:
在QML应用中,我们经常要用到一个SplashScreen的画面来渲染我们的应用。那么我们怎么在自己的应用中做一个Splash Screen呢?
首先我们来设计一个自己的SplashScreen的QML模块:
import QtQuick 2.0
Item {
id: splash
anchors.fill: parent
property int timeoutInterval: 2000
signal timeout
Image {
id: splashImage
anchors.fill: parent
source: "images/splash.jpg"
}
Timer {
interval: timeoutInterval; running: true; repeat: false
onTriggered: {
visible = false
splash.timeout()
}
}
}
import QtQuick 2.0
import Ubuntu.Components 1.1
/*!
\brief MainView with a Label and Button elements.
*/
MainView {
// objectName for functional testing purposes (autopilot-qt5)
objectName: "mainView"
// Note! applicationName needs to match the "name" field of the click manifest
applicationName: "splashscreen.liu-xiao-guo"
/*
This property enables the application to change orientation
when the device is rotated. The default is false.
*/
//automaticOrientation: true
// Removes the old toolbar and enables new features of the new header.
useDeprecatedToolbar: false
width: units.gu(60)
height: units.gu(85)
Page {
title: i18n.tr("Splashscreen")
MainWindow {
id: mainwindow
anchors.fill: parent
visible: false
}
SplashScreen {
onTimeout: {
console.log("it times out!");
mainwindow.visible = true;
}
}
}
}
标签:
原文地址:http://blog.csdn.net/ubuntutouch/article/details/45965665