qml

Python: matplotlib plot inside QML layout

烈酒焚心 提交于 2021-02-08 16:39:11
问题 Consider the following python3 PyQt code to display an interactive matplotlib graph with toolbar import sys, sip import numpy as np from PyQt5 import QtGui, QtWidgets from PyQt5.Qt import * from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar import matplotlib.pyplot as plt app = QApplication(sys.argv) top = QWidget() fig = plt.figure() ax = fig.gca() x = np.linspace(0,5,100)

How to set QML MapPolyline Path Property

走远了吗. 提交于 2021-02-08 14:57:15
问题 I have a MapPolyline object in my QtQuick Project. I need to change the path property from the C++ file, but I have no idea how to do that. My qml - File: MapPolyline { id: mapline objectName: "MapLine" line.width: 5 line.color: "green" path: {[ { latitude: 47.219791, longitude: 9.546032 }, { latitude: 47.219657, longitude: 9.542508 }, { latitude: 47.2194446, longitude: 9.5437876 } ]} } And now I want to change the content of the path property from the C++ file. Thanks for the help! 回答1: Qt

How to create/destroy dynamic objects after the same event in QML?

青春壹個敷衍的年華 提交于 2021-02-08 10:20:47
问题 I have a GridLayout dynamicLayout which has dynamically created/destroyed elements. Create/destroy happens when I click a Button myButton , for which I also provided the code below. GridLayout { id: dynamicLayout anchors.fill: parent Component { id: imageComponent Image { visible: true function deleteImage() { console.log("destroying image") destroy() } } } } Button { id: myButton visible: true x: 200 y: 200 onClicked: { createImageObjects(); } } function createImageObjects() { if

How to create/destroy dynamic objects after the same event in QML?

↘锁芯ラ 提交于 2021-02-08 10:20:23
问题 I have a GridLayout dynamicLayout which has dynamically created/destroyed elements. Create/destroy happens when I click a Button myButton , for which I also provided the code below. GridLayout { id: dynamicLayout anchors.fill: parent Component { id: imageComponent Image { visible: true function deleteImage() { console.log("destroying image") destroy() } } } } Button { id: myButton visible: true x: 200 y: 200 onClicked: { createImageObjects(); } } function createImageObjects() { if

QML: Multi-level Menu from ListModel

只愿长相守 提交于 2021-02-08 09:50:55
问题 I have an example multi-level ListModel: ListModel{ id: myModel ListElement{ name: "File" subItems:[ ListElement{ name: "Open" }, ListElement{ name: "Open Recent" subItems:[ ListElement{ name: "Bla.txt" } ] }, ListElement{ name: "Save" }, ListElement{ name: "Save as" }, ListElement{ name: "Exit" } ] } ListElement{ name: "Edit" subItems:[ ListElement{ name: "Undo" }, ListElement{ name: "Redo" }, ListElement{ name: "Select All" } ] } ListElement{ name: "Help" subItems:[ ListElement{ name:

DropArea doesn't notify about actions onEntered, onExited, onDropped

假装没事ソ 提交于 2021-02-08 06:33:27
问题 I have Rectangle filled with MouseArea which on onPressAndHold() handler reveals second Rectangle and transfers drag action to that Rectangle . The problem is that when I move that second Rectangle over DropArea it doesn't notify about any actions ( onEntered , onExited , onDropped ). I tried to do this in many combinations but it has never worked. Here is an example, am I missing something? import QtQuick 2.0 import QtQuick.Window 2.0 Window { id: appDrawerRoot visible: true width: 360;

DropArea doesn't notify about actions onEntered, onExited, onDropped

微笑、不失礼 提交于 2021-02-08 06:33:24
问题 I have Rectangle filled with MouseArea which on onPressAndHold() handler reveals second Rectangle and transfers drag action to that Rectangle . The problem is that when I move that second Rectangle over DropArea it doesn't notify about any actions ( onEntered , onExited , onDropped ). I tried to do this in many combinations but it has never worked. Here is an example, am I missing something? import QtQuick 2.0 import QtQuick.Window 2.0 Window { id: appDrawerRoot visible: true width: 360;

Deploy Qt 5 QML application to a real Android device

眉间皱痕 提交于 2021-02-08 06:16:33
问题 There are many tutorials how to build an application with Qt for Android. So I do it in these steps: Installed Android SDK, NDK, JDK and Apache Ant Installed Qt 5.2 for Android Created simple QML application. Configured virtual device from AVD Manager I tried to run it and it bringed up Emulator window with my app. OK, it is going as expected. Now I want to run it on real device. I have Samsung Galaxy Tab 2 10.1 P5100 so I enabled USB debug and connected it to PC. But when I run the

Deploy Qt 5 QML application to a real Android device

谁说胖子不能爱 提交于 2021-02-08 06:15:07
问题 There are many tutorials how to build an application with Qt for Android. So I do it in these steps: Installed Android SDK, NDK, JDK and Apache Ant Installed Qt 5.2 for Android Created simple QML application. Configured virtual device from AVD Manager I tried to run it and it bringed up Emulator window with my app. OK, it is going as expected. Now I want to run it on real device. I have Samsung Galaxy Tab 2 10.1 P5100 so I enabled USB debug and connected it to PC. But when I run the

How to set initial value of a custom slider in qml?

≯℡__Kan透↙ 提交于 2021-02-08 04:08:19
问题 I am using Qt 5.4.1. I have made a custom slider element to be used in other qml components like so: Slider.qml import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Controls.Styles 1.3 Item { id: root width: 150 height: 30 property int val: slider.value property int maxVal: slider.maximumValue property int minVal: slider.minimumValue property int step: slider.stepSize Slider { id: slider anchors.margins: 20 stepSize: step maximumValue: maxVal minimumValue: minVal style: customStyle /