为什么 QTCreator 中缺少 Ubuntu.Components 0.1?

Cod*_*ist 13 application-development qt-creator qml ubuntu-touch

首先,我需要使用 QML 和 QT Creator 创建一个“hello world”应用程序,如下所述 http://developer.ubuntu.com/get-started/gomobile/

其次,当我尝试安装 QML 平台和依赖项时,我无法运行第 2 步(“安装 Ubuntu QML 工具包预览版”),因为我有一个基于 ubuntu 12.04 的发行版(backbox),但我按照以下步骤解决了它这篇文章的说明:https : //askubuntu.com/questions/235440/how-do-i-install-the-qml-toolkit-on-12-04

第三,当我打开 QTCreator 并尝试执行CurrencyConverter(helloWorld 应用程序)时,程序找不到以下包:

import Ubuntu.Components 0.1
Run Code Online (Sandbox Code Playgroud)

我该怎么做才能运行该应用程序?

提前致谢。

import QtQuick 2.0
import Ubuntu.Components 0.1

Rectangle {
    id: root
    width: units.gu(60)
    height: units.gu(80)
    color: "lightgray"

    property real margins: units.gu(2)
    property real buttonWidth: units.gu(9)

    Label {
       id: title
       ItemStyle.class: "title"
       text: i18n.tr("Currency Converter")
       height: contentHeight + root.margins
       anchors {
           left: parent.left
           right: parent.right
           top: parent.top
       }
    }
}
Run Code Online (Sandbox Code Playgroud)

Cod*_*ist 3

我至少找到了 ubuntu 12.04 的解决方案。我必须去官方网站http://qt-project.org/downloads#qt-creator并下载最新的Qt包,即Qt 5.0.0。

*注意:Ubuntu 12.04 不包含最新的 Qt 版本,因此您必须手动下载。

*注意:在安装之前我删除了之前版本的 QtCreator (2.5.0)

为了安装 Qt5 软件包,你所要做的就是:

  • chmod 755 qt-linux-opensource-5.0.0-x86_64-offline.run

然后只需执行该包并使用默认设置运行安装程序即可。

  • ./qt-linux-opensource-5.0.0-x86_64-offline.run

  • 现在应该存在/opt/qt5/imports/Ubuntu/Components包含所有库的路径!

之后我按照CurrencyConverter的说明进行操作

*请注意,该行: import Ubuntu.Components 0.1 仍然以红线突出显示,但程序通过选择正常运行 Tools > External > Qt Quick > Preview (qmlviewer)(感谢@David Planella)