qml

Default arguments for qml function gives syntax errors

℡╲_俬逩灬. 提交于 2020-12-30 08:59:19
问题 This code works fine in browser hosted JavaScript environment : function foo(a=true) { console.log(a) } But doing the same in qml is giving syntax error . What might I be doing wrong ? 回答1: In QML, you should write the function as function foo(a) { if (a === undefined) a = true console.log(a) } The syntax function foo(a=true) is not supported as this syntax was introduced in ECMA-262 6th edition while QML only implements the fifth edition (as of Qt 5.11). 回答2: From Qt 5.12, this code will

How to make scrollbar always visible on Flckable in QML

自闭症网瘾萝莉.ら 提交于 2020-12-30 07:49:47
问题 I would like to make Scrollbar.vertical in Flickable area is always visible. currently it is visible upon clicking. Also the text area is overlapping with scroll bar. How can i sepearate scrollbar with text area in the following qml code import QtQuick 2.0 import QtQuick.Controls 2.0 Flickable { id: flickable anchors.fill: parent TextArea.flickable: TextArea { text: "The Qt QML module provides a framework for developing applications and libraries with the QML language. It defines and

Use an offline interactive map in QML

不问归期 提交于 2020-12-29 10:01:31
问题 I'd like to inject a chunk of map that I got from OpenStreetMap under the form of an osm file. From what I've read in the documentation, the Open Street Map Plugin doesn't seem to have any parameter taking a source file as a map. It only works with a server. Problem is I won't have an Internet connection when running my application. I need to use a map internally. Ditto for Mapbox and HERE plugins. Is there any other way to do this? Here is the boilerplate to create a Map: Plugin { id:

TypeError: Cannot read property 'width' of null in QML

做~自己de王妃 提交于 2020-12-15 08:03:08
问题 Item { id: root width: 200 height: head.height property bool state: false property alias root: root property alias head: head property alias body: body property alias title: title property alias image: image property alias mouseArea: mouseArea property var data // when i define data variable in this way, program gets error Tasks { id: tasks } // For call my c++ functions Rectangle { id: head width: parent.width height: 40 color: "#333333" radius: 10 ... } Rectangle { id: body visible: root

TypeError: Cannot read property 'width' of null in QML

自作多情 提交于 2020-12-15 08:01:45
问题 Item { id: root width: 200 height: head.height property bool state: false property alias root: root property alias head: head property alias body: body property alias title: title property alias image: image property alias mouseArea: mouseArea property var data // when i define data variable in this way, program gets error Tasks { id: tasks } // For call my c++ functions Rectangle { id: head width: parent.width height: 40 color: "#333333" radius: 10 ... } Rectangle { id: body visible: root

How to use QKeySequence or QKeySequenceEdit from QML?

末鹿安然 提交于 2020-12-14 23:57:16
问题 Is it possible to use a QKeySequence or QKeySequenceEdit in QML? I only see the documentation for C++ https://doc.qt.io/qt-5/qkeysequence.html#details To provide context, I want a QKeySequence to be input by the user of the application so that I can pass it to my C++ backend so that I can hook into native OS APIs and also serialize it to file. I do not want to actually establish the shortcut within Qt. 回答1: I created a new object that wraps the QKeySequence::toString and makes it available

How to use QKeySequence or QKeySequenceEdit from QML?

倖福魔咒の 提交于 2020-12-14 23:56:11
问题 Is it possible to use a QKeySequence or QKeySequenceEdit in QML? I only see the documentation for C++ https://doc.qt.io/qt-5/qkeysequence.html#details To provide context, I want a QKeySequence to be input by the user of the application so that I can pass it to my C++ backend so that I can hook into native OS APIs and also serialize it to file. I do not want to actually establish the shortcut within Qt. 回答1: I created a new object that wraps the QKeySequence::toString and makes it available

Importing QML from a Resource (QRC) file with PySide2

我怕爱的太早我们不能终老 提交于 2020-12-13 03:12:17
问题 I have added a simple QML component ("qml/MyButton") to my "resource.qrc" file: <RCC> <qresource prefix="/"> <file>qml/MyButton.qml</file> </qresource> </RCC> I then compiled the QRC to a python module with: pyside2-rcc -o resource.py resource.qrc Then I imported resource.py in main.py: import sys import os from PySide2.QtGui import QGuiApplication from PySide2.QtQml import QQmlApplicationEngine import resource if __name__ == "__main__": app = QGuiApplication(sys.argv) engine =

Qt3D: How to scale a Scene2D to be the same size as the window (pixel-wise)?

天涯浪子 提交于 2020-12-13 03:10:55
问题 I created a C++ application with a 800x600 window that successfully draws a few objects in QML using Qt Quick 2 elements as well as Qt 3D objects: The QML code draws a couple of green/yellow rectangles using Qt Quick 2 Rectangle elements inside a Scene2D . Then the 2D scene is blitted to one of the surfaces of a 3D cube for rendering and be displayed within the 3D world. Finally, a blue SphereMesh from Qt 3D is rendered at the center as the screenshot above demonstrates. I've been trying to

QML Connections: Implicitly defined onFoo properties in Connections are deprecated

China☆狼群 提交于 2020-12-05 00:51:45
问题 I got the following error message when upgraded to Qt 5.15: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... } The corresponding QML code is pasted below Connections { target: AppProxy onLogsReady: function(logs) { textLogs.text = logs } } where the onLogsReady is a signal defined in the AppProxy class: class AppProxy : public QObject { Q_OBJECT Q_DISABLE_COPY(AppProxy) public: AppProxy(QObject*