Putting a circle on the map where the user clicks in qml - python

I am trying to get my .qml map to display a circle where the user clicks however keep tying myself in knots. The window output the coordinates to the spinboxes in GeoWidget properly, however I want a circle to appear in that location so the user has some feedback.
coord_map.qml
import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick.Controls.Material 2.0
import QtQuick.Controls.Universal 2.0
import Fluid.Controls 1.0
import QtLocation 5.6
import QtPositioning 5.6
Item {
width: 600
height: 600
Map {
id: map
anchors.fill: parent
zoomLevel: 6
center: (0, 0)
MapItemView {
model: src
delegate: MapQuickItem {
coordinate: src.position.coordinate
anchorPoint.x: image.width * 0.5
anchorPoint.y: image.height
sourceItem: Column {
Image { id: image; source: "marker.png" }
Text { text: title; font.bold: true }
}
}
}
MapCircle {
id: circle
radius: parent.width/10
border.width: 1
color: 'green'
}
}
MouseArea {
id: mouse
anchors.fill: parent
onClicked: {controller.update_from_map(map.toCoordinate(Qt.point(mouse.x, mouse.y)))
circle.center(map.toCoordinate(Qt.point(mouse.x, mouse.y)))
}
plugin: Plugin {
name: "osm"
}
}
}
coordbox.py
import os
import sys
from pathlib import Path
from PySide2.QtCore import Property, Signal, Slot, Qt, QUrl
from PySide2.QtPositioning import QGeoCoordinate
from PySide2.QtQuickWidgets import QQuickWidget
from PySide2.QtWidgets import (
QApplication,
QDialog,
QDialogButtonBox,
QDoubleSpinBox,
QHBoxLayout,
QLabel,
QToolButton,
QVBoxLayout,
QWidget,
QWizard,
QWizardPage,
)
CURRENT_DIRECTORY = Path(__file__).resolve().parent
# TODO: Give the user feedback on where their coordinate is when clicked
class MapDialog(QDialog):
def __init__(self, geo_widget):
super().__init__(geo_widget)
self.setWindowTitle("Map")
self.map_widget = QQuickWidget(resizeMode=QQuickWidget.SizeRootObjectToView)
self.map_widget.rootContext().setContextProperty("controller", geo_widget)
filename = os.fspath(CURRENT_DIRECTORY / "coord_map.qml")
url = QUrl.fromLocalFile(filename)
self.map_widget.setSource(url)
button_box = QDialogButtonBox()
button_box.setOrientation(Qt.Horizontal)
button_box.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok)
lay = QVBoxLayout(self)
lay.addWidget(self.map_widget)
lay.addWidget(button_box)
button_box.accepted.connect(self.accept)
button_box.rejected.connect(self.reject)
class GeoWidget(QWidget):
coordinate_changed = Signal(name="coordinateChanged")
def __init__(self, parent=None):
super().__init__(parent)
self._coordinate = QGeoCoordinate(0, 0)
self._lat_spinbox = QDoubleSpinBox(
minimum=49.0, maximum=56.0 # , valueChanged=self.handle_value_changed,
)
self._lng_spinbox = QDoubleSpinBox(
minimum=-8, maximum=2 # , valueChanged=self.handle_value_changed,
)
self.btn = QToolButton(text="Map", clicked=self.handle_clicked)
self.map_view = MapDialog(self)
# self.coordinate_changed.connect(self.handle_value_changed)
# self.coordinate_changed.connect(self.handle_value_changed)
lay = QHBoxLayout(self)
lay.addWidget(QLabel("Latitude:"))
lay.addWidget(self._lat_spinbox)
lay.addWidget(QLabel("Longitude:"))
lay.addWidget(self._lng_spinbox)
lay.addWidget(self.btn)
#Property(QGeoCoordinate, notify=coordinate_changed)
def coordinate(self):
return self._coordinate
#coordinate.setter
def coordinate(self, coordinate):
if self.coordinate == coordinate:
return
self._coordinate = coordinate
self.coordinate_changed.emit()
def handle_value_changed(self):
coordinate = QGeoCoordinate(
self._lat_spinbox.value(), self._lng_spinbox.value()
)
self.coordinate = coordinate
#Slot(QGeoCoordinate)
def update_from_map(self, coordinate):
self.coordinate = coordinate
self._lat_spinbox.setValue(self.coordinate.latitude())
self._lng_spinbox.setValue(self.coordinate.longitude())
def handle_clicked(self):
self.map_view.exec_()
# Rest of code is used to debug this coordinate box
class WizardPage(QWizardPage):
def __init__(self, parent=None):
super().__init__(parent)
self.geo_widget1 = GeoWidget()
self.geo_widget2 = GeoWidget()
self.registerField("coordinate1", self.geo_widget1)
self.registerField("coordinate2", self.geo_widget2)
lay = QVBoxLayout(self)
lay.addWidget(self.geo_widget1)
lay.addWidget(self.geo_widget2)
def main():
app = QApplication(sys.argv)
w = QWizard()
page = WizardPage()
w.addPage(page)
w.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()
I have had it working however it just shows a blank screen now I am attempting to implement the feedback. I have tried to pick up as much as I can from the documents but not being able to debug qml is causing issues as I don't even know if onClicked can do two things at once (eg. emit the coordinates to the spinboxes and add a feedback circle.

Your code has several things not defined so I will delete them. On the other hand, center is a property, it is not a function, so what you must do is assign the position. It should also be noted that the radius of MapCircle is in meters and not in pixels, so you must choose an appropriate value for the zoom you use.
import QtLocation 5.6
import QtPositioning 5.6
import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick.Controls.Material 2.0
import QtQuick.Controls.Universal 2.0
Item {
width: 600
height: 600
Map {
id: map
anchors.fill: parent
zoomLevel: 6
center: QtPositioning.coordinate(0, 0)
MapCircle {
id: circle
radius: 100000
border.width: 1
color: 'green'
}
MouseArea {
id: mouse
anchors.fill: parent
onClicked: {
var pos = map.toCoordinate(Qt.point(mouse.x, mouse.y));
circle.center = pos;
controller.update_from_map(pos);
}
}
plugin: Plugin {
name: "osm"
}
}
}

Related

How to plot data in QML Qt Charts (with python)

I want to plot data in Qt charts (QML) from python. The x,y data are saved in array x = np.array([0, 6]) y = np.array([0, 250]) . I am desperate how to pass these data to Qt Charts with one step. I can do it (step by step) with Signal/Slot, where the Signal is with parameters (x,y).
My working (very slow) code:
Creating signal from python to qml:
class AppWindow(QObject):
# Signals from python to QML
sigPlotData = Signal(int, int, arguments=['x','y'])
and later () I generate and send data to chart like that:
...
for i in range(50):
self.app.sigPlotData.emit(i, random.randint(0,150))
...
In QML file I do this:
//connections from Python to QML via signals
Connections {
target: backend
function onSigPlotData(x,y){
lineSer.append(x, y);
}
}
ChartView {
id: chartView
title: "Line"
anchors.fill: parent
ValueAxis{
id: axisX
min: 0
max: maxX
}
ValueAxis{
id: axisY
min: 0
max: 150
}
LineSeries {
id: lineSer
name: "data"
axisX: axisX
axisY: axisY
}
}
Thank you very much for help.
you can have this :
in main.py :
import os
from pathlib import Path
import sys
from PyQt5.QtCore import QCoreApplication, Qt, QUrl
from PyQt5.QtWidgets import QApplication
from PyQt5.QtQml import QQmlApplicationEngine
CURRENT_DIRECTORY = Path(__file__).resolve().parent
def main():
app = QApplication(sys.argv)
engine = QQmlApplicationEngine()
filename = os.fspath(CURRENT_DIRECTORY / "main.qml")
url = QUrl.fromLocalFile(filename)
def handle_object_created(obj, obj_url):
if obj is None and url == obj_url:
QCoreApplication.exit(-1)
engine.objectCreated.connect(
handle_object_created, Qt.ConnectionType.QueuedConnection
)
engine.load(url)
sys.exit(app.exec())
if __name__ == "__main__":
main()
and in main.qml :
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtCharts 2.15
ApplicationWindow {
visible: true
width: 600
height: 300
property int timeStep: 0
ChartView {
id: chartView
anchors.fill: parent
ValueAxis {
id: axisX
min: 0
max: 400
}
LineSeries {
id: series1
axisX: axisX
name: "data"
}
}
Timer {
interval: 100
repeat: true
running: true
onTriggered: {
timeStep++;
var y = (1+Math.cos(timeStep/10.0))/2.0;
series1.append(timeStep, y);
}
}
}
Result is:
In QML you can create your function or other things like(for, if,..) with javascript syntax
and as you see I use series1.append(timeStep, y); means append function for adding data.

QML Connections target: refer to Connections parent

I have a qml prototype object ChargeBar defined in ChargeBar.qml. In main project I instance it two times with different ids. I need a slot in Chargebar to send data to. Now I need to write id of target manually in Connections{target: id...} for every instance. Is there any possibility to connect to target automatically?
# This Python file uses the following encoding: utf-8
import os, sys, random
from pathlib import Path
from PySide2.QtGui import QGuiApplication
from PySide2.QtQml import QQmlApplicationEngine
from PySide2.QtCore import QObject, Signal, Slot
APPLICATIONDATA = os.path.join(os.getenv('APPDATA'), "DSController")
class LowLevelControler(QObject):
def __init__(self):
QObject.__init__(self)
nextNumber = Signal(int)
#Slot()
def start(self):
print("giveNumber")
self.nextNumber.emit(random.randint(0, 99))
if __name__ == "__main__":
SERIAL_LLC_RIGHT = "0672FF485550755187034646"
SERIAL_LLC_LEFT = "066AFF575256867067063324"
app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine()
LLC = dict()
LLC["right"] = LowLevelControler()
LLC["left"] = LowLevelControler()
engine.rootContext().setContextProperty("llcRight", LLC["right"])
engine.rootContext().setContextProperty("llcLeft", LLC["left"])
engine.load(os.fspath(Path(__file__).resolve().parent / "main.qml"))
if not engine.rootObjects():
sys.exit(-1)
sys.exit(app.exec_())
main.py <-- entrance
import QtQuick 2.12
import QtQuick.Controls 2.2
import QtQuick.Window 2.12
Window {
id: window
width: 1080
height: 1920
//visibility: "FullScreen"
visible: true
ChargeBar{
id: drawerL
edge: Qt.LeftEdge
llc: llcLeft
}
ChargeBar{
id: drawerR
edge: Qt.RightEdge
llc: llcRight //llcRight=Instance of Python class
Component.onCompleted: llc.nextNumber.connect(reNextNumber)
Connections {
target: drawerR
// PROBLEM: I have to insert target id for every instance manually,
// so I cannot put this passage to ChargeBar.qml */
function onReNextNumber(number) {
print(number)
print("emitted")
}
}
}
Component.onCompleted: drawerR.open()
}
main.qml
import QtQuick 2.12
import QtQuick.Controls 2.12
Drawer {
x:0
y:0
property var llc
signal reNextNumber(int number)
width: 0.66 * window.width
height: window.height
// I want to define Connections here
Button{
id: button
anchors.centerIn: parent
height: 320
width: 320
onClicked: {
llc.start()
}
}
}
ChargeBar.qml
You just have to use the llc object as a target:
ChargeBar.qml
import QtQuick 2.12
import QtQuick.Controls 2.12
Drawer {
id: root
property var llc
signal reNextNumber(int number)
width: 0.66 * window.width
height: window.height
Button {
id: button
anchors.centerIn: parent
height: 320
width: 320
onClicked: llc? llc.start(): null
}
Connections {
target: llc
function onNextNumber(n) {
root.reNextNumber(n)
}
}
}
main.qml
import QtQuick 2.12
import QtQuick.Controls 2.2
import QtQuick.Window 2.12
Window {
id: window
width: 1080
height: 1920
visible: true
ChargeBar {
id: drawerL
edge: Qt.LeftEdge
llc: llcLeft
}
ChargeBar {
id: drawerR
edge: Qt.RightEdge
llc: llcRight
// for testing
onReNextNumber: function(number){
console.log("Test", number)
}
}
Component.onCompleted: drawerR.open()
}

QML slider value using pyqt

I am trying to make QML form for controlling a Servo. So I made a QML form using the QT creator and loaded it using PYQT. From the QML form, I am trying to read a slider value to control the servo. Every time I try to move the slider it says:
AttributeError: 'NoneType' object has no attribute 'value' Aborted
(core dumped)
Here is my pyqt code:
import os
import sys
from PyQt5 import QtCore, QtGui, QtQml
dir_path = os.path.dirname(os.path.realpath(__file__))
class MainWindow(QtQml.QQmlApplicationEngine):
def __init__(self):
super(QtQml.QQmlApplicationEngine, self).__init__()
self.load(QtCore.QUrl.fromLocalFile(os.path.join(dir_path, "QML-1.0.qml")))
self.rootContext().setContextProperty("MainWindow", self)
self.timer = QtCore.QTimer(self)
self.timer.timeout.connect(self.run)
self.timer.start(10)
if self.rootObjects():
# Inherit items from the GUI
self.window = self.rootObjects()[0]
self.text = self.window.findChild(QtCore.QObject, "textField")
self.slider = self.window.findChild(QtCore.QObject, "slider")
def run(self):
print (type(self.slider))
pass
#QtCore.pyqtProperty(int)
def rangeValue(self):
x = self.slider.value()
print x
return 10
if __name__ == '__main__':
app = QtGui.QGuiApplication(sys.argv)
window = MainWindow()
sys.exit(app.exec_())
And here is my qml code:
import QtQuick 2.0
import QtQuick.Window 2.2
import QtQuick.Controls 2.0
import QtQuick.Controls.Universal 2.0
import QtGraphicalEffects 1.0
ApplicationWindow {
id: root
width: 900
height: 300
opacity: 1
title: "window"
visible: true
//visibility: Window.FullScreen
visibility: Window.Maximized
Dial {
id: dial
x: 77
y: 60
width: 102
height: 103
wheelEnabled: true
}
Slider {
id: slider
x: 28
y: 220
value: 0.5
onValueChanged: MainWindow.rangeValue(value)
}
Label {
id: label
x: 64
y: 16
width: 128
height: 24
text: qsTr("Servo-1")
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
}
}
Any help would be appreciated.
Thanks
It seems that you are trying to access a QML element from python which is considered a bad practice so I will not explain where the cause of the error is but I will propose a more stable and recommended solution: Create a QObject, export it to QML and update those properties from QML towards python.
import os
import sys
from PyQt5 import QtCore, QtGui, QtQml
DIR_PATH = os.path.dirname(os.path.realpath(__file__))
class ServoController(QtCore.QObject):
valueChanged = QtCore.pyqtSignal()
def __init__(self, parent=None):
super(ServoController, self).__init__(parent)
self._value = 0
self.valueChanged.connect(self.process_value)
#QtCore.pyqtProperty(float, notify=valueChanged)
def value(self):
return self._value
#value.setter
def value(self, v):
self._value = v
self.valueChanged.emit()
def process_value(self):
print(self.value)
def main():
app = QtGui.QGuiApplication(sys.argv)
engine = QtQml.QQmlApplicationEngine()
servo_controller = ServoController()
engine.rootContext().setContextProperty("servo_controller", servo_controller)
url = QtCore.QUrl.fromLocalFile(os.path.join(DIR_PATH, "QML-1.0.qml"))
engine.load(url)
def on_object_created(obj, objUrl):
if obj is None and url == objUrl:
QtCore.QCoreApplication.exit(-1)
engine.objectCreated.connect(on_object_created, QtCore.Qt.QueuedConnection)
sys.exit(app.exec_())
if __name__ == "__main__":
main()
import QtQuick 2.0
import QtQuick.Window 2.2
import QtQuick.Controls 2.0
import QtQuick.Controls.Universal 2.0
import QtGraphicalEffects 1.0
ApplicationWindow {
id: root
width: 900
height: 300
opacity: 1
title: "window"
visible: true
//visibility: Window.FullScreen
visibility: Window.Maximized
Dial {
id: dial
x: 77
y: 60
width: 102
height: 103
wheelEnabled: true
}
Slider {
id: slider
x: 28
y: 220
value: 0.5
onValueChanged: servo_controller.value = value
Component.onCompleted: servo_controller.value = value
}
Label {
id: label
x: 64
y: 16
width: 128
height: 24
text: qsTr("Servo-1")
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
}
}
In the previous code I created the ServoController class whose function is to map the properties of QML to python such as the value of the slider and call the function process_value when that value changes.
In QML I update the ServoController property when the value of the slider changes and at startup.

an array in python displayed using elements in qml

I should display some rects with qml.
These Rectangle{} the positiopn of those depend on x=array[i][0] and y=array[i][1], and the quantity of those depend on array.lenght().
array in qml should be equal to self.__rectanglePos in Python
So I need a way to draw Rectangle in a different position and in different amount that depends array.
how can I do that?
_____.py
class NN(QObject):
def __init__(self):
QObject.__init__(self)
self.__rectanglePos = [] #each element contains:[x,y,orientation 360°]
#signals
rectanglePosChanged = Signal(type(self.__rectanglePos))
#Slot()
def rects(self):
self.rectanglePosChanged.emit(self.__rectanglePos)
if __name__ == '__main__':
app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine()
qmlRegisterType(NN, 'gnn', 1, 0, 'NN')
engine.load(QUrl.fromLocalFile(gnn.qml))
if not engine.rootObjects():
sys.exit(-1)
sys.exit(app.exec_())
this is not working in qml:
________.qml
#[...]
import gnn 1.0
ApplicationWindow {
ListView{
id: rect
function f(){
for (var i = 0; i < array.lenght(); ++i){
Rectangle {
x: array[i][0]
y: array[i][1]
}
}
}
}
MouseArea{
onClicked: rects()
}
NN{
id: nn
signal getRectangles(var array) // not working
Component.onCompleted: {
nn.rectanglePosChanged.connect(getRectangles)
}
}
Connections {
target: nn
onGetRectangles: {
}
}
}
Your code has many errors, for example you want to access an attribute of the class: self.__rectanglePos) which only makes sense when creating an object from a part of the code that is executed before creating the class: rectanglePosChanged = Signal(type(self.__rectanglePos)), so I will avoid pointing out what your errors are except those necessary for my solution.
If you want to send information as a list where you add, replace or remove items then it is better to use a model as it will notify you in view of the changes. In this case for simplicity I use a QStandardItemModel, so each part of the element as "x" and "y" will be accessed through roles.
In the case of QML, as you want to place Rectangles in any position, using ListView is not the right option since this view restricts the position, instead you must use a Repeater.
main.py
import os
import sys
from PySide2 import QtCore, QtGui, QtQml
XRole = QtCore.Qt.UserRole + 1000
YRole = QtCore.Qt.UserRole + 1001
AngleRole = QtCore.Qt.UserRole + 1002
class RectangleManager(QtCore.QObject):
def __init__(self, parent=None):
super().__init__(parent)
self.m_model = QtGui.QStandardItemModel(self)
roles = {XRole: b"x", YRole: b"y", AngleRole: b"angle"}
self.m_model.setItemRoleNames(roles)
#QtCore.Property(QtCore.QObject, constant=True)
def model(self):
return self.m_model
#QtCore.Slot(float, float, float)
def add_rectangle(self, x, y, angle):
it = QtGui.QStandardItem()
it.setData(x, XRole)
it.setData(y, YRole)
it.setData(angle, AngleRole)
self.model.appendRow(it)
#QtCore.Slot()
def clear_rectangles(self):
self.model.clear()
def main(args):
app = QtGui.QGuiApplication(args)
manager = RectangleManager()
import random
for _ in range(10):
manager.add_rectangle(
random.randint(0, 500), random.randint(0, 500), random.randint(0, 360)
)
engine = QtQml.QQmlApplicationEngine()
engine.rootContext().setContextProperty("rectangle_manager", manager)
current_dir = os.path.dirname(os.path.realpath(__file__))
filename = os.path.join(current_dir, "main.qml")
engine.load(QtCore.QUrl.fromLocalFile(filename))
if not engine.rootObjects():
return -1
ret = app.exec_()
return ret
if __name__ == "__main__":
sys.exit(main(sys.argv))
main.qml
import QtQuick 2.12
import QtQuick.Controls 2.12
ApplicationWindow {
id: root
width: 640
height: 480
visible: true
Repeater{
model: rectangle_manager.model
Rectangle{
x: model.x
y: model.y
rotation: model.angle
width: 100
height: 100
color: Qt.rgba(Math.random(), Math.random(), Math.random(), 1)
}
}
}

How to access QML\QtQuick controls from PySide?

I'm trying to access a FileDialog control from the python file that starts the QQmlApplication engine in order to retrieve the file path property. I have set up a signal in the .qml file, however I cannot access the file dialog by id in the python file to set up the slot. The findChild method in application.py returns None. Here is the code:
application.py
import sys
from PySide2.QtGui import QGuiApplication
from PySide2.QtQml import QQmlApplicationEngine, QQmlFileSelector
sys_argv = sys.argv
sys_argv += ['--style', 'material']
app = QGuiApplication(sys_argv)
window = QQmlApplicationEngine()
window.load("QML/main.qml")
fileDialog = window.findChild(QQmlFileSelector, "fileDialog")
print(fileDialog)
app.exec_()
Page1.qml
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Dialogs 1.2
Page {
width: 600
height: 400
header: Label {
text: qsTr("Prepare Data")
horizontalAlignment: Text.AlignHCenter
font.pixelSize: Qt.application.font.pixelSize * 2
padding: 10
}
Button {
text: qsTr("Load data")
anchors.centerIn: parent
onClicked: fileDialog.visible = true
padding: 10
}
signal folderSelected()
FileDialog {
id: fileDialog
selectFolder: true
title: qsTr("Select the data directory")
folder: shortcuts.home
onAccepted: {
parent.folderSelected()
}
}
}
main.qml
import QtQuick 2.0
import QtQuick.Controls 2.12
import QtQuick.Controls.Material 2.12
ApplicationWindow{
visible: true
title: qsTr("Main window")
width: 1000
height: 800
Material.theme: Material.Light
Material.accent: Material.Orange
SwipeView {
id: swipeView
anchors.fill: parent
Page1 {
}
Page2 {
}
Page3 {
}
}
}
In an old answer explain in the section Pushing References to QML how to update some python object from QML, that methodology is the one recommended by Qt and it is the one that should be used now. With your current method you need to establish an objectname that can be problematic in many cases.
So the solution is to create a QObject that we export to QML and update the qproperty, this will emit a signal that we connect to a slot where we can do the logic that we want. On the other hand FileDialog returns a url, so the property must be a QUrl:
main.qml
import os
import sys
from PySide2 import QtCore, QtGui, QtQml
class FileManager(QtCore.QObject):
file_url_Changed = QtCore.Signal(QtCore.QUrl)
def __init__(self, parent=None):
super(FileManager, self).__init__(parent)
self._file_url = QtCore.QUrl()
def get_file_url(self):
return self._file_url
def set_file_url(self, file_url):
if self._file_url != file_url:
self._file_url = file_url
self.file_url_Changed.emit(self._file_url)
file_url = QtCore.Property(QtCore.QUrl, fget=get_file_url, fset=set_file_url, notify=file_url_Changed)
#QtCore.Slot(QtCore.QUrl)
def on_file_url_changed(file_url):
print(file_url.toLocalFile())
if __name__ == '__main__':
sys.argv += ['--style', 'material']
app = QtGui.QGuiApplication(sys.argv)
file_manager = FileManager()
file_manager.file_url_Changed.connect(on_file_url_changed)
engine = QtQml.QQmlApplicationEngine()
engine.rootContext().setContextProperty("file_manager", file_manager)
file = os.path.join(os.path.dirname(os.path.realpath(__file__)), "QML", "main.qml")
engine.load(QtCore.QUrl.fromLocalFile(file))
if not engine.rootObjects():
sys.exit(-1)
sys.exit(app.exec_())
Page1.qml
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Dialogs 1.2
Page {
width: 600
height: 400
header: Label {
text: qsTr("Prepare Data")
horizontalAlignment: Text.AlignHCenter
font.pixelSize: Qt.application.font.pixelSize * 2
padding: 10
}
Button {
text: qsTr("Load data")
anchors.centerIn: parent
onClicked: fileDialog.visible = true
padding: 10
}
FileDialog {
id: fileDialog
selectFolder: true
title: qsTr("Select the data directory")
folder: shortcuts.home
onAccepted: {
file_manager.file_url = fileDialog.fileUrl // <---
}
}
}

Categories

Resources