qtquick2

How to push values to QML property variant two dimensional array - dynamically?

ⅰ亾dé卋堺 提交于 2019-12-06 03:43:03
问题 This is what I have tried: import QtQuick 2.0 Rectangle { property variant twoDimTempArray: [[]] property variant oneDArray: [1,2,3] MouseArea { anchors.fill: parent onClicked: { twoDimTempArray.push (oneDArray) twoDimTempArray[0].push (oneDArray) twoDimTempArray[0][0] = oneDArray[0] console.log (twoDimTempArray) } } } They all results in [] . How to push values in QML property variant two dimensional array? 回答1: One way to add the values dynamically to a 1 dimensional QML variant is to fill

How GUI screen transition works in qml

送分小仙女□ 提交于 2019-12-06 03:06:39
I'm a C++ developer, now studying about GUI development using QML in QtQuick. In GUI creation, only one screen is visible to the user. And based on user interaction, the screens are switched. But what actually happens behind? There are lot of info only on how to design a single screen, but very less resource for how to manage the transitions of their states. Are all the screens and components loaded when starting the application and change the layer order to display once screen, OR after an user action, the new screen is built, loaded and old is destroyed ( only one screen is in memory at a

QML - MouseArea/MouseEvent issue

别说谁变了你拦得住时间么 提交于 2019-12-06 03:01:44
The following piece of code generates a white rectangle containing a red rectangle and a grey rectangle. Every rectangle has an associated MouseArea. The grey rectangle becomes blue when the mouse is clicked inside it. The red rectangle prints a console message when the mouse cursor enters inside it and another message when the released signal is emitted. I would like to: press and hold the mouse button inside the grey rectangle (becoming blue) move the cursor outside the grey/blue rectangle and then inside the red rectangle, without releasing the button and capturing the entered signal of the

Reject external files dragged in a DropArea without breaking the DropArea

我是研究僧i 提交于 2019-12-05 23:55:43
问题 In my application I'm displaying a list of audio files and the user can drag an external file to add it to the list. I want to be able to refuse the drag if no file in the list is supported by my application. The issue is that when I call drag.accepted = false; in onEntered of my DropArea then it becomes completely unresponsive to any other event. Here is some sample code showing the issue. If you drag an MP3 in the window you see that it works. Then if you drag any other file it won't work,

Animate `positionViewAtIndex`

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 23:45:08
I have ListView showing a Model, in which, at random positions I might add a entry. Now I want to see my new entry, and try to move the ListView to it, with the positionViewAtIndex(newIndex, ListView.Visible) But this change somtimes feeles very hard. Is there a posibility to smooth it with som animation? A somewhat lengthy example to play with: import QtQuick 2.7 import QtQuick.Controls 2.0 ApplicationWindow { width: 1024 height: 800 visible: true property int lastAddedIndex: -1 onLastAddedIndexChanged: lv.positionViewAtIndex(lastAddedIndex, ListView.Contain) Button { property int num: 10

Appending object with Javascript array to a QML ListModel causes SEGFAULT

我的未来我决定 提交于 2019-12-05 20:37:23
I am using QtQuick on Android. I am trying to append a Javascript object with an array property to a ListModel . I use LocalStorage to store this data. The object I materialise from the database has this array property, and when I try and append that object to the ListModel I get a SEGFAULT. If I do not include an array in my object, or in fact if the array is empty, then it will successfully append to the ListModel and will not SEGFAULT. When I materialise the object from the database, I do this: var movie = { id: row.id, title: row.title, genres: ['a', 'b', 'c'] } I'm creating a Javascript

How to stop ListView for “jumping” when model is changed

放肆的年华 提交于 2019-12-05 18:56:32
问题 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 the past messages without jumping at the end every time I receive a new message. The problem : After scrolling up, every time I receive a new message it jumps at the beginning of list. To solve that I manage to store the contentY of the list and

Set common property value in QML such as QSS

大城市里の小女人 提交于 2019-12-05 16:39:53
For example i have 2 different QML elemnts with common property such as: import QtQuick 2.0 Rectangle { width: 360 height: 360 Text { id: t color: "red" text: qsTr("Hello World") anchors.top: parent.top } TextInput { text: qsTr("Hello all!") color: "red" anchors.top: t.bottom } } You can see, that Text and TextInput have equal property called "color" with equal value. In QSS i can use common property value, for example: QWidget { background: "red" } and all QWidgets, that belong the qss widget also will have red background. Is way for set common property in QML? There is no support for

Adding Items to a layout of a custom component

扶醉桌前 提交于 2019-12-05 16:21:32
I have a custom Footer Component which I would like to reuse in different place in my QML App: Rectangle { color: "gold" height: 50 anchors { bottom: parent.bottom left: parent.left right: parent.right } RowLayout { anchors.fill: parent anchors.margins: 10 Button { text: "quit" } } } The use of this is easy: Window { visible: true Footer { } } But now I would like to add a "ButtonA" to the RowLayout of my Footer in one view and a "ButtonB" in another view. How can I achieve that? Mitch See this answer. You have to declare a default property in Footer.qml : import QtQuick 2.0 import QtQuick

Is there any possibility to reach the index of an outer QML Repeater from the inner one (they are nested)?

给你一囗甜甜゛ 提交于 2019-12-05 15:29:05
I am trying to dynamically build a matrix of the same type of items in my QML application and keep it dynamic, so that you can change the number of rows and columns in a c++ file anytime. This has been working well, but now, to access them individually, I want to give them dynamic names. Therefore I nested two repeaters and tried to set the objectName as in the following: Repeater{ id: rows model: Matrix1.row //number of rows in Matrix1-Object Repeater{ id: columns model: Matrix1.column //number of columns in Matrix1-Object RepeatedItem{ objectName: (index) +"."+ (rows.index) //matrix elements