我想尝试用 QML 为 ubuntu-touch 创建一个应用程序!
我创建了一个简单的应用程序:
import QtQuick 2.0
import QtQuick.Controls 1.1
import Ubuntu.Components 0.1
import "components"
/*!
\brief MainView with a Label and Button elements.
*/
import QtQuick.LocalStorage 2.0
import QtQuick.Layouts 1.1
MainView {
// objectName for functional testing purposes (autopilot-qt5)
objectName: "mainView"
// Note! applicationName needs to match the "name" field of the click manifest
applicationName: "com.ubuntu.developer.z-admin-angels-gmail-com.oweMe"
/*
This property enables the application to change orientation
when the device is rotated. The default is false.
*/
automaticOrientation: true
width: units.gu(100)
height: units.gu(75)
Page {
title: i18n.tr("oweMe")
Column {
anchors.rightMargin: 8
anchors.bottomMargin: 8
anchors.leftMargin: 24
anchors.topMargin: 24
spacing: units.gu(1)
anchors {
margins: units.gu(2)
fill: parent
}
Row {
id: gridButton
x: 218
y: 30
width: 541
height: 65
Button {
objectName: "addDebpt"
text: i18n.tr("add debpt")
color: UbuntuColors.midAubergine
onClicked: {
var component = Qt.createComponent("qml/MyQmlFile.qml");
if (component.status == Component.Ready)
component.createObject(label1, {"x": 100, "y": 100});
}
}
/*Button {
width: 153
objectName: "addCommunBuy"
text: i18n.tr("add commun Buy")
color: UbuntuColors.lightAubergine
onClicked: {
}
}*/
Button {
width: 153
objectName: "removeDebpt"
text: i18n.tr("remove debpt")
color: UbuntuColors.lightAubergine
onClicked: {
}
}
} // ButtonGRID
}
GridLayout {
id: gridForm
x: 42
y: 92
width: 622
height: 340
Label {
id: label1
x: 227
y: 218
width: 272
height: 89
text: qsTr("Open QML HERE")
font.pointSize: 21
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WrapAnywhere
}
}
} // grid Content
}
当我通过 ubuntu i386 模拟器运行我的应用程序时,应用程序崩溃了...或者当我用桌面运行它时,我没有问题
应用程序输出:
Executing: /tmp/com.ubuntu.developer.username.oweme_0.1_all.click Launcher PID: 4502 AppId: com.ubuntu.developer.username.oweme_oweMe_0.1 Architecture: all
Transaction: Installing files Status: Waiting in queue Status: Starting Status: Finished Transaction: Installing files Status: Waiting in queue Status: Waiting for authentication Status: Waiting in queue Status: Starting Status: Finished Results: Installed com.ubuntu.developer.username.oweme-0.1.all (installed:click,removable=1,app_name=oweMe) Application installed, executing Registering hooks Start Application Application started: 4572
Received a failed event The Application exited, cleaning up Transaction: Removing Status: Waiting in queue Status: Starting Status: Finished Transaction: Removing Status: Waiting in queue Status: Waiting for authentication Status: Waiting in queue Status: Starting Status: Finished Results:
和一般输出:
[15:38:15] ii 点击审阅者工具 0.8-0~214~ubuntu14.04.1
和我的编译输出:
16:28:56: Running steps for project oweMe...
sending incremental file list
deleting qtc_device_debughelper.py
./
oweMe.desktop
oweMe.json
sent 682 bytes received 89 bytes 1.54K bytes/sec
total size is 46.47K speedup is 60.27
16:28:56: The process "/usr/bin/rsync" exited normally.
WARNING:root:Ignoring missing framework "ubuntu-sdk-14.10-dev2"
Successfully built package in './com.ubuntu.developer.username.oweme_0.1_all.click'.
16:28:56: The process "/usr/bin/click" exited normally.
16:28:56: The click package has been created in /home/morgan/build-oweMe-ubuntui386_GCC_i386_ubuntu_sdk_14_10_utopic-default
16:28:56: Connecting to device...
16:28:57: Uploading file '/home/morgan/build-oweMe-ubuntui386_GCC_i386_ubuntu_sdk_14_10_utopic-default/com.ubuntu.developer.username.oweme_0.1_all.click'...
16:28:57: Uploading file '/usr/share/qtcreator/ubuntu/scripts/qtc_device_applaunch.py'...
16:28:57: All files successfully deployed.
16:28:57: Deploy step finished.
16:28:57: Elapsed time: 00:02.
答案1
我找到问题了!
它崩溃了,因为我使用
import QtQuick.Controls 1.1
没有这个,它工作得很好