qtquickcontrols

How to apply opacity mask to a QML item?

谁都会走 提交于 2019-12-18 06:17:09
问题 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

QML Form layout (GridLayout) troubles

那年仲夏 提交于 2019-12-18 05:03:58
问题 I am trying now to convert my app UI from C++ to QML. At some step I need a login window so I created it in QML with code below: Window { id: loginWindow property string username: login.text; property string password: password.text; property bool issave: savePassword.checked; flags: Qt.Dialog modality: Qt.WindowModal width: 400 height: 160 minimumHeight: 160 minimumWidth: 400 title: "Login to program" GridLayout { columns: 2 anchors.fill: parent anchors.margins: 10 rowSpacing: 10

How to scroll to certain row in QML TreeView

℡╲_俬逩灬. 提交于 2019-12-13 02:58:32
问题 In TreeView , selecting a row by clicking it. But I want to focus the row in TreeView by indicating the row QModelIndex and roleName . I found similar function in ListView : positionViewAtIndex(int index, PositionMode mode) How to do this in TreeView ? 回答1: Try to use hidden variable __listView. __listView.positionViewAtIndex(row, mode) 来源: https://stackoverflow.com/questions/46441998/how-to-scroll-to-certain-row-in-qml-treeview

QQuickView: handling mouse events in C++

不打扰是莪最后的温柔 提交于 2019-12-12 15:18:10
问题 I render my 3d model under qml controls using QQuickView::beforeRendering event. I want to do my mouse events handling in C++ if user clicks outside any of qml controls/ How can I found out in QQuickView::mousePressEvent that mouse is pressed outside qml controls? 回答1: I think it's easier to do it with a custom QQuickItem , because doing it with a custom QQuickView apparently means that you get the events before they reach any of the items. Here's an example: #include <QtQuick> class MyItem :

How to take Screenshot of QML application without QQuickView

女生的网名这么多〃 提交于 2019-12-12 07:58:49
问题 I want to grab screen of my QML application. But my root QML object is ApplicationWindow , so I can't use QQuickView to show it. Instead I have to use QQmlApplicationEngine . I know how to take screenshot with QQuickView ( QQuickWindow::grabWindow ), but don't know how to take it with QQmlApplicationEngine . My main file: int main(int argc, char *argv[]) { QApplication app(argc, argv); ApplicationData appData; QQmlApplicationEngine engine; engine.load(QUrl("qrc:///main.qml")); return app.exec

QML progress bar is NOT showing up on UI

可紊 提交于 2019-12-11 07:21:29
问题 I have this QML progress bar: import QtQuick.Controls 2.0 as QQC20 Item { QQC20.ProgressBar { id: progressbar_id visible: false // even if "true", the progress bar does NOT show up on UI from: editorScene.progressbarMin to: editorScene.progressbarMax value: editorScene.progressbarVal onValueChanged: { console.log("Progressbar value changed: ", progressbar_id.value) } onVisibleChanged: { console.log("Progressbar visibility chanaged: ", progressbar_id.visible) } } } I can confirm that the

How to make rectangle height fill ScrollView

白昼怎懂夜的黑 提交于 2019-12-11 03:44:46
问题 I have the following QML code: import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Window 2.2 Window { id: win width: 1024 height: 768 visible: true ScrollView { id:scrollView anchors.fill: parent Rectangle{ id:rect z:5 color:"red" width: 2048 height: win.height border{ color: "black" width: 2 } } } } In this code the larger Rectangle makes the horizontal scrollbar correctly appear. However, since the scrollbar takes some height from the window, the vertical scrollbar appears too.

“Bind” two QML CheckBoxes together, ensuring their states are always identical

最后都变了- 提交于 2019-12-11 00:57:46
问题 I'd like to create two checkboxes on different pages of a GUI such that they are semantically the "same" checkbox -- same label, same effect. (Having them on both pages is just for the user's convenience.) This requires "binding" two CheckBox QML elements together such that the state of one is always reflected by the other, and vice-versa. This is equivalent to what's being asked here, except I'm using QML/JS instead of JS/JQuery. I thought that a naive implementation of binding the checked

Disable mouse wheel for QML Slider

让人想犯罪 __ 提交于 2019-12-10 20:48:28
问题 I want to be able to scroll Flickable with mouse wheel (or two fingers on touchpad) without changing Slider s it may containt. Sample code and result application: import QtQuick 2.7 import QtQuick.Window 2.2 import QtQuick.Controls 1.4 ApplicationWindow { id: rootWindow visible: true width: 400 height: 200 title: qsTr("Hello World") ScrollView { anchors.fill: parent flickableItem.flickableDirection: Flickable.VerticalFlick Column { Repeater { model: 40 Slider { width: rootWindow.width * 0.9 }

Image size different after second click on it

╄→尐↘猪︶ㄣ 提交于 2019-12-10 18:42:03
问题 I have following minimal working example, taken from my current project: import QtQuick 2.5 import QtQuick.Window 2.2 import QtQuick.Layouts 1.1 import QtQuick.Controls 1.4 Window { visible: true width: Screen.width/2 height: Screen.height/2 property real ueMinOpacity: 0.00 property real ueMaxOpacity: 1.00 Rectangle { anchors.fill: parent anchors.margins: 8 border.color: "#4682b4" radius: 16 clip: true gradient: Gradient { GradientStop { position: 0 color: "#ffffff" } // GradientStop