qtquick2

How to use a ListView with custom item QML

北城余情 提交于 2020-01-17 08:30:45
问题 I am a newbie in QML. I made thanks to internet ressources this accordion : Item { default property var contentItem: null property string title: "panel" id: root Layout.fillWidth: true height: 30 Layout.fillHeight: current property bool current: false ColumnLayout { anchors.fill: parent spacing: 0 Rectangle { Drag.active: dragArea.drag.active id: bar Layout.fillWidth: true height: 30 color: root.current ? "#81BEF7" : "#CEECF5" Text { anchors.fill: parent anchors.margins: 10

Rendering a section of a non-smooth QImage using QSGImageNode

假装没事ソ 提交于 2020-01-17 05:51:12
问题 I'm trying to render individual tiles from a tileset. For example, I want to display the grey tile in the tileset below: In the real use case, these would be e.g. water, grass, etc. tiles in a game. There are some requirements for rendering these tiles: They are 32x32 pixels and will be rendered fullscreen, so performance is important. They should not be smoothed when scaled. None of the built-in Qt Quick types meet these requirements (rendering a section of an image that's not smoothed), as

Unable to assign QList<QUrl> to QString

雨燕双飞 提交于 2020-01-16 08:14:09
问题 I'm encountering this error: Unable to assign QList<QUrl> to QString when trying to directly assign the result of drop.urls (obtained from DropArea 's onDropped handler) to a Label's text property in Python. Based on this doc, I tried Qt.resolvedUrl (to convert the type to a string) as shown in the following code. However, it results in an empty text label. The urls I'm working with start with " file:/// ". What am I doing wrong? import QtQuick.Window 2.2 import QtQuick 2.2 import QtQuick

Change order of visible items

好久不见. 提交于 2020-01-16 05:51:07
问题 Is it possible to move up/down the visual items in order to change its overlapping? currently, the child hides its parent, but i'd like to have the reverse, i.e. the parent hides the child. Maybe some properties exists? 回答1: Yes it's possible. You will need to change the z property of the involved items. According to the documentation: Sets the stacking order of sibling items. By default the stacking order is 0. Items with a higher stacking value are drawn on top of siblings with a lower

ListView.model does not work well

冷暖自知 提交于 2020-01-16 02:55:10
问题 In the following code I have a ListView which I feed with JSON data. I use the parse function to extract data and assign it to the model, i.e. : view.model = JSON.parse(io.text) However, it seems that view.model don't get the data so that my application can't show anything. Here is my full code. import QtQuick 2.0 import FilesIO 1.0 import QtQuick.Window 2.2 import QtQuick.Controls 1.3 import QtQml 2.2 ApplicationWindow{ id: root width: 320 height: 410 title:"LOLLLLL" color: "white" visible:

ListView.model does not work well

我是研究僧i 提交于 2020-01-16 02:55:01
问题 In the following code I have a ListView which I feed with JSON data. I use the parse function to extract data and assign it to the model, i.e. : view.model = JSON.parse(io.text) However, it seems that view.model don't get the data so that my application can't show anything. Here is my full code. import QtQuick 2.0 import FilesIO 1.0 import QtQuick.Window 2.2 import QtQuick.Controls 1.3 import QtQml 2.2 ApplicationWindow{ id: root width: 320 height: 410 title:"LOLLLLL" color: "white" visible:

Two-dimensional table with nested scrolling areas in QML

我只是一个虾纸丫 提交于 2020-01-14 03:09:09
问题 I want to create, in QML, a TV-schedule where the vertical axis is a list of Channels and the horizontal axis is time-based. For example something like (source: zappware.com) Initially, I created a vertical ListView with model = the list of Channels delegate = a horizontal ListView every horizontal ListView has model = the list of Events delegate = an Item where the width is proportional to the duration of the Event So far so good. Only drawback is that the horizontal ListViews scroll one by

What is the difference between Row and RowLayout?

情到浓时终转凉″ 提交于 2020-01-12 06:58:11
问题 This works as intended with Row , but not with RowLayout . Why? What is the difference between the two? ApplicationWindow { title: "Testing" width: 640 height: 480 //RowLayout { Row { anchors.fill: parent Rectangle { id: rect1 width: parent.width * 0.3 height: parent.height color: "blue" } Rectangle { height: parent.height width: parent.width * 0.7 color: "red" } } } 回答1: Row is a Item Positioner. Positioner items are container items that manage the positions of items in a declarative user

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

 ̄綄美尐妖づ 提交于 2020-01-12 06:54:28
问题 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 } MouseArea { anchors.fill: parent onClicked: { Qt.quit(); } } } main.cpp #include <QtGui/QGuiApplication> #include <QQmlEngine> #include <QQmlComponent> #include <QQmlProperty> #include <QDebug> #include "qtquick2applicationviewer.h" int main(int argc, char *argv[]) { QGuiApplication app(argc, argv)

How to specify wildcards in .qrc resource file of QML?

落爺英雄遲暮 提交于 2020-01-11 05:48:05
问题 There are x number of .png files in a directory. Instead of adding all these manually I would want to specify the directory path in the .qrc file and let it include all of them on its own. What is the way to achieve this? 回答1: No, this is not yet possible, see this bugreport for details. 回答2: Here is a little bash script that generate a qrc file from the content of a folder #!/bin/sh QRC=./resourcefilename.qrc echo '<!DOCTYPE RCC>' > $QRC echo '<RCC version="1.0">' >> $QRC echo ' <qresource>'