我想使用 Qt 来开发 Ubuntu 桌面、手机和平板电脑应用程序,但我不想学习新的编程语言(C++、JavaScript)。是否可以使用 Qt-Creator 作为 IDE 在 Python 中编写 Qt 应用程序?
因此,在构建我需要flickable用于滚动的 Ubuntu 应用程序时,现在我有了以下形式的代码
Page{
...
Flickable {
anchors.fill: parent
content.height: element1.height + element2.height ...
...
}
}
Run Code Online (Sandbox Code Playgroud)
当我在手机上运行它时(ubuntu utopic),flickable 的默认位置比标题低几百像素。当我轻弹它时,它停留在它应该从一开始就停留的正确位置。此外,当使用 pagestack 推送另一个页面时,然后回到这个页面,它保持在正确的位置。为什么会这样,我该如何修复它,以便它从一开始就处于正确的位置。
注意:我已经尝试了多种锚点、宽度、高度等的组合。有一次我确实让它保持在该位置,但是当向上弹时它与标题重叠。
programming application-development qt-creator qml ubuntu-sdk
我正在开发一个用于 Ubuntu-Touch 的阅读器应用程序。从应用程序阅读书籍时,锁定纵向或横向方向将是一个有用的功能。当在床上侧身阅读时,这会很有用。
我尝试使用automaticOrientation = false or true,但是,当设置为 false 时,SDK 当前锁定纵向方向。
有没有办法将设备屏幕的方向锁定在一个或另一个中并保持锁定?
更新:
较新版本的 Ubuntu for Phone 具有锁定方向的全局选项,但是,我仍然希望在应用程序级别执行此操作。
我仍在寻找一种方法来做到这一点。
application-development orientation qml ubuntu-sdk ubuntu-touch
我想从我的应用程序内部运行系统命令。假设使用 SSH 在远程服务器上运行命令。但这不是重点。关键是我不知道如何从应用程序运行任何类型的命令。我在邮件列表中询问,他们推荐我使用 C++ 构建 QML 扩展。但是我不懂 C++,似乎我必须学习这么多才能运行一个简单的命令。
在 Python 中(如在 PHP 中),很容易运行系统命令。在我的 Touch 应用程序中还有其他方法可以做到这一点,或者有人可以帮助我更多吗?或者也许对我的问题有更好的解决方案?
在我的应用程序中,我使用 OptionSelector 从自行车站列表中进行选择。我还有一个地图组件,每个站都有地标。
当我点击一个地标时,它也会将 OptionSelector 更改为相应站的索引,因为这是很好的 UX。
不好的 UX 是 OptionSelector 如何响应这个索引变化,它自己动画,就好像它被用户的手指轻弹一样。换句话说,在用户点击地图标记并接收到他们需要的所有信息后很久,OptionSelector 仍在“旋转”到站的索引。
这是演示此行为的视频:https : //www.youtube.com/watch?v=jXKWlAmNYsw
我想让这个 OptionSelector 立即改变它的索引,没有动画。有没有办法做到这一点?
这是我目前做事的方式。如果这是错误的处理方式,我很高兴得到纠正。我使用 WorkerScript(一个 QML 线程,或多或少)来进行 API 调用。当这个 WorkerScript 返回时,它会像这样移动 OptionSelector:
WorkerScript {
id: queryStationsWorker
source: "../js/getstations.js"
onMessage: {
[...]
// Move the OptionSelector to the corresponding station's index.
stationSelector.selectedIndex = getLastStationIndex(lastStation.contents.stationName, stationsModel)
/*
* For the sake of clarity:
*
* getLastStationIndex() is a function which just returns an integer.
* lastStation is a U1DB database used for state saving.
* …Run Code Online (Sandbox Code Playgroud) 你如何检查一个属性是否在 qml 中未定义?
这就是我想要做的:
Button {
id: myButton
text: if (text === "undefined"){"default text"}
}
Run Code Online (Sandbox Code Playgroud) 首先,我需要使用 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) 我想编写一个基于 Python ( PySide ) 和QML的QtQuick应用程序。
我知道 Qt 应用程序有自己的翻译技术,但我想坚持使用gettext来解决这个问题。我想知道是否可以:
.pot文件我知道这是在Unity 2D 代码中完成的,在 C++ 中,所以我想知道如何使用 Python 完成它。
注意:我说的是在运行时只使用 gettext,而不是在 gettext 和 Qt Linguist 格式之间进行转换。
我正在尝试使用以下代码向选项卡组件添加一个新选项卡。
运行时不会报告错误,但不会显示其他选项卡。我试过同时使用 tabs 和 tabs.__tabsModel 作为父级,但没有显示其他选项卡。
import QtQuick 2.0
import QtQuick.LocalStorage 2.0
import Ubuntu.Components 0.1
MainView {
// objectName for functional testing purposes (autopilot-qt5)
id: mainView
objectName: "mainView"
applicationName: "news-feed"
width: units.gu(100)
height: units.gu(75)
Tabs {
id: tabs
anchors.fill: parent
Component.onCompleted: {
mainView.initializeDB();
mainView.saveFeed("BBC News","http://feeds.bbci.co.uk/news/rss.xml");
mainView.saveFeed("Jono Bacon","http://www.jonobacon.org/?feed=rss2");
mainView.saveFeed("The Register", "http://www.theregister.co.uk/headlines.atom");
fillTabs();
}
tools: ToolbarActions {
Action {
objectName: "action"
iconSource: Qt.resolvedUrl("avatar.png")
text: i18n.tr("Tap me!")
onTriggered: {
label.text = i18n.tr("Toolbar tapped")
}
}
}
// First tab begins here
Tab { …Run Code Online (Sandbox Code Playgroud) Ubuntu 接口工具包文档记录了 QML 元素的主题化,其语法与 CSS 非常相似。这对我来说听起来很棒,但我无法开始使用它。我尝试了很多,但我想我错过了一些基本问题的答案:
也许我没有理解文档的一个重要部分。英语不是我的母语,因此我很难获得这个特定的文档。
qml ×10
ubuntu-touch ×6
ubuntu-sdk ×5
qt ×3
qt-creator ×3
programming ×2
c++ ×1
gettext ×1
orientation ×1
python ×1