qml

QML Charts causes crash on startup

怎甘沉沦 提交于 2021-02-17 05:06:32
问题 I'm trying to make an application that uses QML QCharts to visualize data. The program is crashing at startup before a window even appears. I tried on both macOS and Windows 10 with the same results. I have included a minimally working example below. main.py : import sys from PySide2.QtGui import QGuiApplication from PySide2.QtQml import QQmlApplicationEngine from PySide2.QtCore import QUrl import qml_rc if __name__ == "__main__": app = QGuiApplication(sys.argv) engine = QQmlApplicationEngine

Is it possible to get a list of objects from a PySide2 slot (service call) via QML?

给你一囗甜甜゛ 提交于 2021-02-17 03:50:29
问题 I am trying to convert an existing PySide2/QtWidgets application to PySide2/QML. I am trying to get a list of custom objects from a Python service call via a QML MouseArea click. I currently have a main script ( main.py ) that launches a QQuickView containing my QML (contained in main.qml ). It also registers a custom type for my model ( Role , defined in role.py ) and exposes an instance of my service class (contained in mock_role_service.py ) to the view's root context. My QML displays

how can I transfer Component.onCompleted:{} method from ui.qml to .qml?

和自甴很熟 提交于 2021-02-17 02:00:19
问题 I am developing a project by seperating ui.qml files and .qml files . So, I am writing the functionality codes(javascript codes) into .qml file and I am writing design codes in ui.qml file . However I have a problem with using Component.onComplete functionality in .qml file. for example : MapDisplayForm.ui.qml Item{ id:item1 property alias map1 Map{ id: map1 Component.OnCompleted : { //this is the function that i should write in Map.qml } } } MapDisplay.qml MapDisplayForm{ //it does not

How to add a rectangle to a QML ChartView?

眉间皱痕 提交于 2021-02-16 18:22:58
问题 I want to put a number of rectangles as overlays to show regions of interest on a ChartView of ScatterSeries. However when I try to do this it is clearly using a different coordinate system to that of the ScatterSeries as it is drawn in a completely different place. For example the following is intended to draw a rectangle that captures all of the ScatterSeries but it just draws a small green rectangle top left as shown in the screenshot. ChartView { id: view Layout.fillWidth : true Layout

QML Layouts: How to give weights to items in a row or column layout?

廉价感情. 提交于 2021-02-16 16:30:10
问题 I'm trying to figure out a way to layout items proportionally by specifying a kind of weight for each item. For example the way Android does their layouts. The way I'm trying to achieve it is like so: import QtQuick 2.10 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 GridLayout { columns: 4 width: 640 height: 480 Rectangle { color: "red" Layout.fillHeight: true Layout.fillWidth: true Layout.columnSpan: 1 } Rectangle { color: "#80000000" Layout.fillHeight: true Layout.fillWidth: true

QML - How to correctly set an implicitWith to a GridLayout

有些话、适合烂在心里 提交于 2021-02-11 14:14:00
问题 I'm using Qml 5.12 and basically trying to set an implicitWidth to a GridLayout. For that, I have a purple rectangle and set the rectangle's width to the GridLayout. The red rectangle fit with the GridLayout so I can see the width of my GridLayout. Here's my code: Rectangle { anchors.fill: gl; color: "red"; opacity: 0.22 } Rectangle { id: rect; width: 350; height: 30; color: "purple"; } GridLayout { id: gl y: 35 implicitWidth: rect.width columns: 2 Label { text: "This is a test" } SpinBox {

How to detect when Text gets elided

筅森魡賤 提交于 2021-02-11 13:01:45
问题 My UI contains a Text field with horizontalAlignment: Text.AlignJustify maximumLineCount: 5 wrapMode: TextEdit.WordWrap elide: Text.ElideRight When the text does not fit, the last line should end with "... MORE" where "MORE" should be focusable. This will probably be a separate Text field where the visibility is controlled by whether or not the text is elided. But how can I detect when a Text gets elided? 回答1: When a Text gets elided, it is truncated. Here's a simple example: Text { id:

Editing a QVariantMap from QML

久未见 提交于 2021-02-11 12:56:58
问题 I have a QVariantMap created in C++ from a JSON object and I want to update this object from QML. I set it as a context property. // main.cpp engine.rootContext()->setContextProperty("myjson", myqvariantmap); In QML I tried updating its properties but it seems to be read-only. The docs support this, saying Mind that QVariantList and QVariantMap properties of C++ types are stored as values and cannot be changed in place by QML code. You can only replace the whole map or list, but not

Changing Background color of window on button click in qml

浪尽此生 提交于 2021-02-11 12:17:26
问题 I developing qml project in that i want to add functionality of changing background color .. for that i create one combo box with items {red,blue,white} and create one update button to update color when user select red item and click on update background color change as red so how can i do ?? Button { id: button1 x: 284 y: 95 width: 114 height: 34 text: qsTr("Update") contentItem: Text { font: control.font opacity: enabled ? 1.0 : 0.3 text: "Update" //Font.pixelSize:15 horizontalAlignment:

nextItemInFocusChain function not working in qml on mac?

家住魔仙堡 提交于 2021-02-11 12:07:06
问题 I have a form where i've done a custom field that only accepts the top, right and bottom arrows. But to accept the tab navigation i'm using the following chain of functions: nextItemInFocusChain().forceActiveFocus() The problem is that this is working on windows but not on mac ... I've a formulary to illustrate the problem where next to that "code text field" i have a comboBox where i want, that when the user clicks on tab in the "code text field" to navigate to. It seems that it only