qtquickcontrols

Is there a native data model from TreeView in QML?

烈酒焚心 提交于 2020-02-23 04:12:57
问题 The QT document had implied that any implementation of QAbstractItemModel can be used for TreeView. These models are usually in C++, which is inconvenient for now. So is there an native QML model which can be utilized in treeview? Can I set a QStandardItemModel model from C++, and use this model in qml? 回答1: The QStandardItemModel reference gives an example of how to use it for a TreeView: QStandardItemModel model; QStandardItem *parentItem = model.invisibleRootItem(); for (int i = 0; i < 4;

Is there a native data model from TreeView in QML?

拟墨画扇 提交于 2020-02-23 04:12:44
问题 The QT document had implied that any implementation of QAbstractItemModel can be used for TreeView. These models are usually in C++, which is inconvenient for now. So is there an native QML model which can be utilized in treeview? Can I set a QStandardItemModel model from C++, and use this model in qml? 回答1: The QStandardItemModel reference gives an example of how to use it for a TreeView: QStandardItemModel model; QStandardItem *parentItem = model.invisibleRootItem(); for (int i = 0; i < 4;

QML ListView populate property does not work (its animation)

你离开我真会死。 提交于 2020-01-23 12:29:45
问题 I have following QML ListView inside ueLoginWindow : import QtQuick 2.0 import QtMultimedia 5.5 import QtQuick.Controls 1.3 import QtQuick.Extras 1.4 import QtQuick.Layouts 1.2 import QtQuick.Window 2.2 import QtTest 1.1 import Enginio 1.0 import QtBluetooth 5.5 import QtCanvas3D 1.0 import QtLocation 5.5 import QtNfc 5.5 import QtPositioning 5.5 import QtQuick.LocalStorage 2.0 import QtQuick.XmlListModel 2.0 import QtSensors 5.5 import QtWebChannel 1.0 import QtWebKit 3.0 import QtWebSockets

QML ListView populate property does not work (its animation)

删除回忆录丶 提交于 2020-01-23 12:29:07
问题 I have following QML ListView inside ueLoginWindow : import QtQuick 2.0 import QtMultimedia 5.5 import QtQuick.Controls 1.3 import QtQuick.Extras 1.4 import QtQuick.Layouts 1.2 import QtQuick.Window 2.2 import QtTest 1.1 import Enginio 1.0 import QtBluetooth 5.5 import QtCanvas3D 1.0 import QtLocation 5.5 import QtNfc 5.5 import QtPositioning 5.5 import QtQuick.LocalStorage 2.0 import QtQuick.XmlListModel 2.0 import QtSensors 5.5 import QtWebChannel 1.0 import QtWebKit 3.0 import QtWebSockets

How to dynamically update a child combobox from parent combobox

可紊 提交于 2019-12-25 00:25:44
问题 I have a QML app that has two combo boxes, one is parent (country) combo box, other one is child (city) combo box. When selecting a country, the child combo box should have cities of the country at the same time. I have a code that first combo box selects country but it doesn't set the list model of city's combo box. It sets after reopening the app. import QtQuick 2.11 import QtQuick.Window 2.11 import QtQuick.Controls 2.4 import QtQuick.Layouts 1.3 import Qt.labs.settings 1.0

how to sort QML TableView in QtQuick 2?

£可爱£侵袭症+ 提交于 2019-12-21 03:01:20
问题 I want to implement a sortable TableView with custom roles with Qt 5.1. But I don't know what to do more to make it sorted when user clicked on header. in my Qt .pro file, I added: !android: !ios: !blackberry: qtHaveModule(widgets): QT += widgets in main.cpp, I used QtWidgets/QApplication as global app instance, and used qmlRegisterType for my new model class(see below): qmlRegisterType<PositionModel>("MyDataModule", 1, 0, "PositionModel"); PositionModel is declared following: class

How to package custom controls in QML?

99封情书 提交于 2019-12-20 04:58:10
问题 I would like to create a library of QML custom controls that I would provide to my customers. At the same time I don't want my customers to "reverse-engineer" my controls by peeking into the QML source code. What are my best options to avoid this? The ideal scenario would that I provide my controls as a compiled library that they could import in their own projects. My target platforms are iOS and Android. 回答1: How can I create the package for custom QML controls? These controls should not be

ReferenceError in qt quick controls tabview

不问归期 提交于 2019-12-19 11:24:15
问题 I have written a QT Quick program use TabView. When I click the botton b1 which is in Tabview, the program should call show_text() and print the text of b1, but it print "ReferenceError: b1 is not defined". Any suggestion will be appreciated, thanks. import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Window 2.1 ApplicationWindow { function show_text() { console.log(b1.text) } TabView { id: tv Tab { id: tab1 Button{ id: b1 text:"b1's text" onClicked: { //console.log(b1.text) show

BusyIndicator does not show up

拈花ヽ惹草 提交于 2019-12-19 03:22:53
问题 I want to show a BusyIndicator while a long process is going on. The problem is it does not show up when I make it run and shows afterwards when the process is completed. According to the docs The busy indicator should be used to indicate activity while content is being loaded or the UI is blocked waiting for a resource to become available. I have created a minimal code that based upon the original code Window { id: win width: 300 height: 300 property bool run : false Rectangle { anchors.fill

How to apply opacity mask to a QML item?

守給你的承諾、 提交于 2019-12-18 06:18:16
问题 The look and feel I'm trying to go for is to have a solid color button, and text on it like "Hello World" where the text is completely transparent, and the background shows through the button. In other words, having text as a transparency mask on a button element. 回答1: Here is one way to do it: // TB.qml MouseArea { width: txt.contentWidth + 20 height: txt.contentHeight + 10 property alias text: txt.text property alias color: sh.color ShaderEffect { id: sh anchors.fill: parent property color