qtquick2

Animate `positionViewAtIndex`

别等时光非礼了梦想. 提交于 2019-12-10 09:50:19
问题 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

Set common property value in QML such as QSS

为君一笑 提交于 2019-12-10 09:40:50
问题 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

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

╄→尐↘猪︶ㄣ 提交于 2019-12-10 05:10:41
问题 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 /

Change text color for QML controls

六眼飞鱼酱① 提交于 2019-12-10 04:21:06
问题 I am using some QML controls like GroupBox and CheckBox which have text associated with them. The default color of the text is black. However, I have these items on a dark background and would prefer using white for the text color. These items don't have a color property so I'm not sure what to do. CheckBox { text: "Check Me" } 回答1: You need to use the style property to redefine the Component to use for the label based on the CheckBoxStyle import QtQuick 2.1 import QtQuick.Controls 1.0 import

Custom source property for VideoOutput QML

半腔热情 提交于 2019-12-09 03:40:43
What exactly has to be done to provide custom source of frames for VideoOutput QML object? Does VideoOuput itself provide an instance of QAbstractVideoSurface class to the "source"? The Qt5 documentations says following thing about providing about this issue: If you are extending your own C++ classes to interoperate with VideoOutput, you can either provide a QObject based class with a mediaObject property that exposes a QMediaObject derived class that has a QVideoRendererControl available, or you can provide a QObject based class with a writable videoSurface property that can accept a

Difference between qt qml and qt quick

假装没事ソ 提交于 2019-12-08 22:46:19
问题 I'm confused with QML, QtQuick 1.0 and QtQuick 2.0. What's the difference between them? I use QtCreator 2.8.1 based on Qt 5.1.1. I want to develop a desktop program, which technology should I use? 回答1: EDIT: Please refer to @TheBootroo for a better answer Although my answer was accepted by the OP, I want to revise (or even) remove my answer. My answer was based on personal experiences with respect to Qt 5.2 in 2013 some of which is no longer valid today: QML is Qt Meta Language or Qt

How to reproduce the layout of the Windows 10 settings window in QML?

半城伤御伤魂 提交于 2019-12-08 15:36:20
问题 I would like to implement in QML a Page with customized ToolButtons to look like and behave like the Windows 10 settings screen: The fixed size buttons should always be centered horizontally in the page spanning across variable number of rows depending on the width of the window. If the height of the window is sufficient to display all the buttons, they should be centered vertically as well, otherwise a vertical scrollbar should be provided to scroll the contents. The buttons should have an

QObject gets destroyed after being put into QML variable

这一生的挚爱 提交于 2019-12-08 15:28:35
Today I've faced strange bug in our program. The object of a class inherited from QObject was being deleted by event with type QEvent::DefferedDelete , while nobody could possibly send it. It was passed into QML as QVariant: // cpp: Q_INVOKABLE QVariant currentDevice_v() const { return QVariant::fromValue(_current); } // qml: Component.onCompleted: { curDevice = devicesModel.currentDevice_v() #... } Without that qml line everything worked well - nothing produces delete event. ProdoElmit What I've figured out that if I set the parent of that QObject before I pass it into QML, then it doesn't

QObject gets destroyed after being put into QML variable

穿精又带淫゛_ 提交于 2019-12-08 08:45:23
问题 Today I've faced strange bug in our program. The object of a class inherited from QObject was being deleted by event with type QEvent::DefferedDelete , while nobody could possibly send it. It was passed into QML as QVariant: // cpp: Q_INVOKABLE QVariant currentDevice_v() const { return QVariant::fromValue(_current); } // qml: Component.onCompleted: { curDevice = devicesModel.currentDevice_v() #... } Without that qml line everything worked well - nothing produces delete event. 回答1: What I've

How to cache complex item into texture and release the memory for the actual complex item?

我怕爱的太早我们不能终老 提交于 2019-12-08 06:38:20
问题 I've got a big number of items that are quite complex (memory-heavy), and in order to fit in limited RAM, I want to cache some of them into textures and not keep the actual complex item in memory. In particular, items for which I want to do that are all those (among my complex items) that do not currently need to animate (and this means most of them). For the purposes of this question I call this kind of items "inactive". My plan was: When an item "foo" becomes inactive: Create dynamically a