Questions tagged [qtquick2]

Qt Quick is a modern user interface technology that separates the declarative UI design and the imperative programming logic. Instead of the traditional C++ APIs of Qt, the presentation layer of the application is written with a Qt-specific declarative language called QML.

The Qt Quick module is the standard library for writing QML applications. While the Qt QML module provides the QML engine and language infrastructure, the Qt Quick module provides all the basic types necessary for creating user interfaces with QML. It provides a visual canvas and includes types for creating and animating visual components, receiving user input, creating data models and views and delayed object instantiation.

The Qt Quick module provides both a QML API which supplies QML types for creating user interfaces with the QML language, and a C++ API for extending QML applications with C++ code.

For more details, see the introduction to Qt Quick page in the Qt reference documentation.

2305 questions
15
votes
5 answers

Qt5 Syntax Highlighting in QML

I am working on a QtQuick 2.0 presentation and I would like to embed some code samples. is it possible easily to create a syntax highlighting QML element. The objective in question is to apply syntax highlighting to a TextEdit or a TextArea. I know…
Itay Grudev
  • 7,055
  • 4
  • 54
  • 86
14
votes
2 answers

How to align items in RowLayout

I want to align Rectangles in a RowLayout left to right. In below code example two Rectangles share additional space instead stack one after another. I used Layout.alignment: Qt.AlignLeft in RowLayout level and Rectangle level, but non of those two…
s1n7ax
  • 2,750
  • 6
  • 24
  • 53
14
votes
1 answer

Passing a Javascript callback to a C++ Invoked method in Qml

In C++ I have a class with an invokable function, what I would like to do is call that method from QML/Javascript (this I've gotten to work) and pass it a Javascript callback. In code, I define my class like: class MyObject: public…
Addy
  • 2,414
  • 1
  • 23
  • 43
14
votes
1 answer

How to access the QML object inside the Loader's sourceComponent?

I may need to read or write to some of the properties of the Loader's sourceComponent from some outside function. What is the way to access the property x of the object inside this Loader's sourceComponent? import QtQuick 2.0 Item { width:…
Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411
14
votes
8 answers

Deploy Qt5 QML application

To test QML deployment I've created a very simple QML application. Here is the code: main.cpp #include #include #include int main(int argc, char **argv) { QApplication app(argc, argv); …
folibis
  • 12,048
  • 6
  • 54
  • 97
14
votes
3 answers

Sending a signal to a QML item from C++ (Qt5)

I have a QML file containing this: Text { id: testData onTaskClicked:{ testData.text = task.name } } The catch is this taskClicked signal. It is emitted by another widget (C++) and needs to be relayed to QML. This is similar to…
Einar
  • 4,727
  • 7
  • 49
  • 64
14
votes
5 answers

How to implement QML ListModel like get method for an QAbstractListModel derived model

I want to use an QAbstractListModel derived model in QML. Binding the model to views already works great. The next thing I want achieve is the ability to access specific items and their role like it is possible with a QML…
avb
  • 1,701
  • 5
  • 22
  • 37
14
votes
3 answers

How to access a nested QML object from C++?

Here is a reproducible example: main.qml import QtQuick 2.0 Item { id : root width: 360 height: 360 Text { id : t1 text: qsTr("Hello World") property int someNumber: 1000 anchors.centerIn: parent …
Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411
13
votes
2 answers

Use the size of a model in QML

I am looking for a way to access the number of elements that are to be found in a model in QML. For example: Item { id: root Row { id: row height: root.height width: root.width spacing: 5 Repeater { …
13
votes
4 answers

QML ListView hidden delegate item

Is there any way to hide certain item in ListView? import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Window 2.2 ApplicationWindow { title: qsTr("Hello World") width: 640 height: 480 visible: true ListView { …
user2672883
  • 141
  • 1
  • 6
13
votes
2 answers

How to stop ListView for "jumping" when model is changed

What I need to do: I need to create a chat window using a ListView in QML that stores the chat-messages. I set listView.positionViewAtEnd() in order to follow the last messages. I disable positionViewAtEnd when I scroll upwards such that I can read…
Ispas Claudiu
  • 1,890
  • 2
  • 28
  • 54
13
votes
1 answer

Working with .ui.qml files

In Qt 5.4, the template when creating a new "QtQuick UI File" generates two files: MyScreen.qml and MyScreen.ui.qml. The MyScreen.ui.qml file seems to be for UI only, since Qt Creator suggests you should only edit it in design mode. That implies…
Tim
  • 4,560
  • 2
  • 40
  • 64
13
votes
3 answers

How to write conditional import statements in QML?

Like we have preprocessor directives in C++ for conditional includes. Similarly, how to do conditional importing in QML? if x import ABC 1.0 else import PQR 2.0
Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411
13
votes
4 answers

How to find out which fonts are available in qml?

I would like to know which fonts I can use in a QML environment for the font.family property. Are these fonts system-specific or are they built into the framework? Is there any way to list all available fonts?
FourtyTwo
  • 1,616
  • 2
  • 15
  • 43
13
votes
4 answers

How to create and use C++ objects in QML Javascript

My app uses both c++ and QML. I've defined several objects in C++ part to access SQL etc. It looks like: class MyObject : public QObject { Q_OBJECT public: MyObject(QObject *parent = 0); Q_INVOKABLE void someFunction(const QString…
folibis
  • 12,048
  • 6
  • 54
  • 97