Hot answers tagged

18

Just desing your interface in Qt-Designer and convert it to python file executing pyuic4. Eg: pyuic4 editorFrame.ui -o editorFrame.py then you can import it from your main class, in this case i'm using a QMainWindow: import sys from PyQt4 import QtGui from editorFrame import Ui_MainWindow class Editor(QtGui.QMainWindow): def __init__(self): ...


14

Yes, Qt-Creator is a C++ IDE, with little support for other languages but since version 2.8.0 a quite basic python support has been added. That said you can use Qt-Designer (the form building tool), Qt-Translator (the translate tool), etc... easily with python. There are two Qt-Python bindings right now, the GPL/Commercial dual licensed PyQt, and the LGPL ...


13

This isn't something that QML supports, the typical answer is to write a C++ plugin to handle that kind of thing. However, the SDK team is planning out various extensions to provide to QML app developers, and this may be something that they implement in a generic plugin that you can use.


13

You can use QChart.js - QML bindings for Charts.js (a simple HTML5 Charts javascript library using the canvas element) I forked the project here to support resize events (for a desktop use). I basically need to reset the canvas context to allow resize events to properly redraw the surface with an updated window size (See http://qt-project.org/forums/...


12

Apparently a drop needs to be generated explicitly by calling the drop() method on the Drag object Try adding this line inside of the MouseArea, just above drag.target: parent onReleased: parent.Drag.drop()


12

Try: text: text ? text : "default text" "undefined" is just a string representation of a reference not referencing anything, just like None, or NULL in other languages. === is strict comparison operator, you might want to read this thread: https://stackoverflow.com/questions/523643/difference-between-and-in-javascript


11

Update: For 14.04 see the much simplified answer by int_ua. Original Text: At http://talk.maemo.org/showthread.php?t=87580 there is a basic overview of how to add the extension to QML. I decided to give it a shot using the ubuntu-sdk instead, which is slightly different. I'll document below. For this project I selected Ubuntu Touch/Simple UI with C++ ...


9

You can use almost all the javascript syntax in QML (See http://qt-project.org/doc/qt-5/ecmascript.html). The fastest method is Math.round(<NUM> * 100) / 100 But (<NUM>).toFixed(2) works (but is too slow according to this question on SO) The following snippet of code presents both implementations: import QtQuick 2.0 import Ubuntu.Components 0....


9

A convenient way for developers to do app testing is by starting them through adb. To make that convenient we are providing a cli tool, called ubuntu-app-launch. So create a remote connection with phablet-shell and start your applications using their desktop filename: ubuntu-app-launch com.ubuntu.calculator_calculator_1.3.316 ubuntu-app-launch dialer-...


8

With the release of Qt Creator 2.8 things are changing. It now natively supports Python for code editing and there are few Python-based features. From Qt Creator 2.8 release announcement: An editor specific for Python was added, with highlighting and indentation, and a Python class wizard


8

Well, Qt is owned by Digia, not related to Ubuntu/Canonical. Qt itself is licensed under the GNU Lesser General Public License (LGPL) version 2.1. This allows you to create and redistribute your closed source apps very well, as long as you're dynamically linking to Qt, or adhere to the limitations of statically linking. See also these Q&A on SO: Use ...


8

Problem solved, the answer is to use QtMultimedia 5.0, which now provides the Audio element. http://qt-project.org/doc/qt-5.0/qtmultimedia/qml-qtmultimedia5-audio.html


8

You can us the SQLite offline storage API directly from Qml using Javascript: import QtQuick.LocalStorage 2.0 If you want in-depth examples, I'd suggest looking at the source of some of the Ubuntu Touch Core-Apps. I know that at least the weather, clock, and RSS reader apps all use this. For now though, here's a simple example: import QtQuick.LocalStorage ...


8

gu is short for grid unit. From the user interface manual: Measurement Units A new measurement unit is defined called the grid unit, abbreviated gu. 1 grid unit translates to a given number of pixels depending on the type of screen that the user interface is displayed on. For example, on a laptop computer 1 grid unit will typically translate to 8 pixels. ...


7

These instructions were tested on Ubuntu 12.04, Ubuntu 12.10 both 32-bit and 64-bit. First off we need to install some dependencies. Install these even if you already have Qt5 installed: sudo apt-get install build-essential libgtk2.0-dev libgl1-mesa-dev If you haven't already, download and install the QtSDK from http://qt-project.org/downloads. For ...


7

There will be; we're working on it. I plan to have the QML U1DB declarative API published soon. In the meantime, until that arrives, you may find this code interesting; it is a simple notes app, but written with QML and using U1DB. This U1DB QML addition follows the declarative QML U1DB API I mentioned above, but it's a Python-based prototype of that API. ...


7

Ubuntu 14.04 The concept of QProcess Launcher type is now working without problems in Trusty with ubuntu-sdk-team PPA. Just create QML Extension Library + Tabbed UI project (don't use hyphens in project name yet), replace contents of mytype.h #ifndef LAUNCHER_H #define LAUNCHER_H #include <QObject> #include <QProcess> class Launcher : ...


7

This property holds the name of the object. The objectName is a QString property of QObject which defaults to an empty QString. You usually set this property when you need to find QML elements from Qt. By this way the signals, properties and functions of a QML element can be accessed from Qt (C++) code. Autopilot tests use this property to introspect your ...


7

You can do it using some Javascript code in QML: import QtQuick 2.0 import Ubuntu.Components 0.1 Item { width: 200 height: 150 ListModel { id: model } ListView { id: listview anchors.fill: parent model: model delegate: Text { text: jsondata } } function getData() { ...


6

In default 12.10 it seems to be provided by libqtwebkit4. But that package is from Qt4, so I suppose you are using qt5-edgers ppa to provide Qt5. There you have two packages that can solve your problem: sudo apt-get install libqt5webkit5-qmlwebkitplugin libqt5webkit5 So if you are using that PPA install those two packages and see if it solves your problem. ...


6

No. You can also use Java, Python, C, Javascript, QML, Vala, and C#, and probably other languages too. Source (archived)


6

If there is no QML module that can help you accessing IRC servers, you will probably need to write a QML plugin in C++ that does that work as a backend. You can then use QML to implement the UI frontend.


6

Changing aspects of the layout depending on the size of the window can be accomplished in a number of ways. At the most basic level, you can just set properties to different values based on the dimensions. Here is a minimal example that draws a grey square that turns orange if you make the window bigger: Run with qmlscene path/to/file.qml import QtQuick 2....


6

Qt Quick Controls are available since Qt 5.1 and the Qt 5 version in Ubuntu repositories seems to be Qt 5.0.2. Consequently you cannot use Qt Quick Controls with the current version of Qt5 in Ubuntu repositories. If you want to use them, you have got 3 options: Using official Qt Project packages for Linux. You can download them here. Waiting a version of ...


6

The i18n portion is the component name, and the tr() function is the function to translate a string, in the Ubuntu SDK, with QML. This method of translation support uses gettext, and not the built-in localization features of Qt/QML, which are not compatible with gettext.


6

You can use QML basic types or the generic var property. The var type is a generic property type that can refer to any data type. It is equivalent to a regular JavaScript variable. For example, var properties can store numbers, strings, objects, arrays and functions. The following code will demonstrate the use of both basic types and var ...


6

The Ubuntu SDK comes with its own styled TextField element. On dark background you can use the default Qt version by importing QtQuick.Controls (14.04 only). It will always render a white background but can also be styled with TextFieldStyle: import QtQuick 2.0 import Ubuntu.Components 0.1 import QtQuick.Controls 1.1 import QtQuick.Controls.Styles 1.1 ...


6

The following code should do what you need by putting the Image into a MouseArea component: import QtQuick 2.0 MouseArea { width: my_background.width height: my_background.height Image { id: my_background source: "background.png" } onClicked: my_background.source = "background.png" }


6

Logs for your application can be found in the ~/.cache/upstart/ folder on your device. I'd recommend to open/cat them using a remote connection (with phablet-shell)


Only top voted, non community-wiki answers of a minimum length are eligible