qml

qml FolderListModel

♀尐吖头ヾ 提交于 2020-01-01 09:18:40
问题 I am trying to use FolderListModel, according to this example like this: ListView { anchors.fill: parent FolderListModel { id: foldermodel folder: "C:/Qt/Projects/" showDirs: true showDotAndDotDot: true nameFilters: ["*"] sortField : "Name" } Component { id: filedelegate Text { text: fileName } } model: foldermodel delegate: filedelegate } i want to show all the files/directories under the base directory, in a recursive way. does any one have an idea how to do that? 回答1: It seems that you

Qt 5.4/Qml: Prevent binding loop

谁都会走 提交于 2020-01-01 09:10:10
问题 I have a global singleton "Settings" which holds application settings. When I try to run the following code I get a QML CheckBox: Binding loop detected for property "checked" : CheckBox { checked: Settings.someSetting onCheckedChanged: { Settings.someSetting = checked; } } It is obvious why this error occurs, but how can I correctly implement this functionality without a binding loop? E.g. I want to save the current checked state of the checkbox in the settings singleton. I am using Qt 5.4

HTML formatting in QML Text

99封情书 提交于 2020-01-01 08:47:23
问题 I have a part of HTML code, which displays small table. In browser it looks like in the picture: But when I want to display it in Text QML (which, according to the documentation, should support HTML), I see: (Orange rectangle is a part of rectangle, which is parent of mytext ) Text { id: mytext anchors.fill: parent text: "<div><table border='1'><caption><h4>Test stats</h4>"+ "</caption><tr bgcolor='#9acd32'><th/><th>Number1</th><th>Number2</th></tr> <tr><th>Line1</th>"+ "<td> 0 </td> <td> 1 <

HTML formatting in QML Text

こ雲淡風輕ζ 提交于 2020-01-01 08:47:06
问题 I have a part of HTML code, which displays small table. In browser it looks like in the picture: But when I want to display it in Text QML (which, according to the documentation, should support HTML), I see: (Orange rectangle is a part of rectangle, which is parent of mytext ) Text { id: mytext anchors.fill: parent text: "<div><table border='1'><caption><h4>Test stats</h4>"+ "</caption><tr bgcolor='#9acd32'><th/><th>Number1</th><th>Number2</th></tr> <tr><th>Line1</th>"+ "<td> 0 </td> <td> 1 <

ListElement fields as properties?

本小妞迷上赌 提交于 2020-01-01 08:03:27
问题 Here is my code : import QtQuick 1.0 ListModel { property real firstValue: 2 property real secondValue: 3 property real thirdValue: 1 id: leftGrid ListElement { icon: "Images/1.png" value: leftGrid.firstValue } ListElement { icon: "2.png" value: -1 } ListElement { icon: "3.png" value: leftGrid.secondValue } ListElement { icon: "4.png" value: leftGrid.thirdValue } } This gives me the error: ListElement: cannot use script for property value What should I do? 回答1: I had this problem as well.

ListElement fields as properties?

做~自己de王妃 提交于 2020-01-01 08:03:02
问题 Here is my code : import QtQuick 1.0 ListModel { property real firstValue: 2 property real secondValue: 3 property real thirdValue: 1 id: leftGrid ListElement { icon: "Images/1.png" value: leftGrid.firstValue } ListElement { icon: "2.png" value: -1 } ListElement { icon: "3.png" value: leftGrid.secondValue } ListElement { icon: "4.png" value: leftGrid.thirdValue } } This gives me the error: ListElement: cannot use script for property value What should I do? 回答1: I had this problem as well.

qt: invalid property name 'x' (M16) for button

非 Y 不嫁゛ 提交于 2020-01-01 05:27:20
问题 I'm using Qt 5.4.1 in QtCreator 3.3.1 I've imported QtQuick.Controls 1.2 into my QML and added a series of buttons: Rectangle { id: buttonBar x: 480 y: 0 width: 320 height: 80 Button { x: 0 y: 0 width: 80 height: 60 text: "Songs" } Button { x: 80 y: 0 width: 80 height: 60 text: "Artists" } Button { x: 160 y: 0 width: 80 height: 60 text: "Albums" } Button { x: 240 y: 0 width: 80 height: 60 text: "Back" } } They all render fine when I run the program, but everytime that QtCreator opens the qml

Can't load Image source in QML Image

∥☆過路亽.° 提交于 2020-01-01 04:07:46
问题 This seems really basic but for some reason I can't get the image source to work in the ultra-simple QML app below. FYI, I'm running Mac OS-X 10.9.5, Qt Creator 3.2.1 based on Qt 5.3.2. import QtQuick 2.3 import QtQuick.Controls 1.2 ApplicationWindow { visible: true width: 640 height: 480 title: qsTr("Test") Image { id: image1 x: 10 y: 10 width: 100 height: 100 source: "testImage.png" } } I get the following error: qrc:/main.qml:10:5: QML Image: Cannot open: qrc:/testImage.png The application

Draw a dashed and dotted bezier curve in QML

时光毁灭记忆、已成空白 提交于 2019-12-31 20:15:29
问题 I've seen there is an example implementation of a Bezier curve in QML, but I'm looking for a hint how to implement dashed or dotted bezier curve line. As far as I see, tha authors of Bezier curve example are using QSGGeometryNode to store inside QSGGeometry with a QSGFlatColorMaterial material applied on it. Then they simply create list of points and draw segments between them. Is it possible to write a shader and apply it to QSGFlatColorMaterial (to display line as dashed , dotted , etc)?

Access Listview currentIndex from Delegate

*爱你&永不变心* 提交于 2019-12-31 18:00:43
问题 I have a QML ListView where the delegate loads it's component from another file. When clicking on an delegate item, I want to update ListView . CurrentIndex and highlight the selected item. It works, when I explicitly set the id of the ListView . However since I want to use the delegate's Component also for other ListView s, I'm stuggeling to find a generic way how to access ListView.currentIndex from within a delegate Component . Here is the Code: main.qml import QtQuick 2.4 import QtQuick