qtquickcontrols2

Open and close additional window (QML)

旧城冷巷雨未停 提交于 2019-12-11 02:01:47
问题 Currently I have a window openning in the following way: property variant win Button { id: testButton MouseArea { onClicked: { var component = Qt.createComponent("test.qml"); win = component.createObject(testButton); win.show(); } } } Is it ok to create a window like this or there is a better way to do it (from QML, not from C++)? When I close this additional window (just by clicking "x" button), I want to connect it to another event (for example, changing color of the button). How to do it?

QML - How to get children in an item?

僤鯓⒐⒋嵵緔 提交于 2019-12-10 11:57:18
问题 I had a problem with the item in QML. I wanna get children of an item but it seems working in the first element. The detail code is below: I have a gridview with a list custom component AAA_Styles GridView{ id: grdViewDeviceControl clip: true interactive: true ScrollIndicator.vertical: ScrollIndicator{} cellWidth: 200 cellHeight: 300 model: ListModel{} delegate: Item { width: grdViewDeviceControl.cellWidth height: grdViewDeviceControl.cellHeight AAA_Styles{ id: deviceControl objectName:

How to implement a master-details view Qt/QML on an Android tablet?

♀尐吖头ヾ 提交于 2019-12-10 11:26:16
问题 I am porting an iOS app to Qt/QML targeting an Android tablet. I would like to keep the app's behavior similar to the original iOS version, which is based on a UISplitViewController . In other words, I need to build a master-details view using the tablet in landscape mode. In order to achieve this, I was thinking of using ListView backed by a ListModel as the master view so that whenever an item is selected in the ListView , a details view is dynamically displayed. At the moment I am

QML: Mid-swipe position of item in SwipeView

僤鯓⒐⒋嵵緔 提交于 2019-12-10 09:27:51
问题 I'm trying to create a Parallax View based on a SwipeView element. Examples in QML documentation illustrate how to achieve it with ListView: Image { id: background source: "background.png" fillMode: Image.TileHorizontally x: -list.contentX / 2 width: Math.max(list.contentWidth, parent.width) } ListView { id: list anchors.fill: parent spacing: 20 snapMode: ListView.SnapToItem orientation: ListView.Horizontal highlightRangeMode: ListView.StrictlyEnforceRange boundsBehavior: Flickable

Qt accessing model data outside ItemDelegate

我是研究僧i 提交于 2019-12-08 06:08:54
问题 I have some model class that inherits QAbstractListModel : VehiclesModel.h : class VehiclesModel : public QAbstractListModel { Q_OBJECT public: enum Roles { ImagePathRole = Qt::UserRole + 1, // QString NameRole // QString }; virtual int rowCount(const QModelIndex & parent = QModelIndex()) const override { ... } virtual QVariant data(const QModelIndex & index, int role) const override { ... } virtual QHash<int, QByteArray> roleNames() const override { QHash<int, QByteArray> roles =

Qt accessing model data outside ItemDelegate

旧城冷巷雨未停 提交于 2019-12-07 15:08:34
I have some model class that inherits QAbstractListModel : VehiclesModel.h : class VehiclesModel : public QAbstractListModel { Q_OBJECT public: enum Roles { ImagePathRole = Qt::UserRole + 1, // QString NameRole // QString }; virtual int rowCount(const QModelIndex & parent = QModelIndex()) const override { ... } virtual QVariant data(const QModelIndex & index, int role) const override { ... } virtual QHash<int, QByteArray> roleNames() const override { QHash<int, QByteArray> roles = QAbstractListModel::roleNames(); roles[ImagePathRole] = "imagePath"; roles[NameRole] = "name"; return roles; } };

How change the color of “Qt Quick - Control 2 RoundButton”

ⅰ亾dé卋堺 提交于 2019-12-07 12:42:44
问题 Anybody know how I can change the color of the control "RoundButton", present in the present in Qt Controls since 2.1. I tried changing the background, but if I put "Rectangle" at the item the RoundButton became rectangular and I don't know what to put instead. RoundButton { id: roundButton x: 243 y: 244 width: 20 height: 20 text: "ah" wheelEnabled: false background: Rectangle { color: "yellow" height: 50 width: 50 } } 回答1: With Qt 5.10 you can use the palette property to avoid having to

How to set currentIndex of SwipeView to currentIndex of TabBar “by reference” after going to specific page?

╄→гoц情女王★ 提交于 2019-12-07 04:18:54
问题 I'm getting started with QtQuick Controls 2.0. I have experience with C++ and a small amount of experience with Qt, but I have not worked with QML before. I have a TabBar and a SwipeView that are linked to each other. What I mean by this is that when you select a page on the TabBar , the SwipeView goes to that page. When you swipe to a page from the SwipeView , the TabBar updates itself to reflect that. As a learning exercise, I decided to create a button that would send the user to the

System tray icon without widgets

99封情书 提交于 2019-12-07 01:00:29
问题 I'm wondering if there's a way to implement system tray icon + menu functionality without widgets module? 回答1: Qt 5.8 introduces a SystemTrayIcon QML type in the experimental Qt Labs Platform module, as part of the Qt Quick Controls 2 offering. It uses a native implementation directly from the Qt Platform Abstraction layer where available, and Qt Widgets as a fallback on other platforms. 来源: https://stackoverflow.com/questions/41095630/system-tray-icon-without-widgets

QML: Mid-swipe position of item in SwipeView

不羁岁月 提交于 2019-12-05 11:56:36
I'm trying to create a Parallax View based on a SwipeView element. Examples in QML documentation illustrate how to achieve it with ListView: Image { id: background source: "background.png" fillMode: Image.TileHorizontally x: -list.contentX / 2 width: Math.max(list.contentWidth, parent.width) } ListView { id: list anchors.fill: parent spacing: 20 snapMode: ListView.SnapToItem orientation: ListView.Horizontal highlightRangeMode: ListView.StrictlyEnforceRange boundsBehavior: Flickable.StopAtBounds maximumFlickVelocity: 1000 model: _some_cpp_list //Loader is used as a workaround for QTBUG-49224