qml

How can I let users use control + + for zoom in and control + - for zoom out?

旧城冷巷雨未停 提交于 2019-12-31 05:32:06
问题 The problem with my code below is that on US/UK keyboard layouts + is generated with shift + = , but when the user uses both the control and shift modifiers simultaneously, + is not generated. This has been tested on Mac. Keys.onPressed: { if (event.modifiers & Qt.ControlModifier) { if (event.key === Qt.Key_Minus) { zoom(false) event.accepted = true } else if (event.key === Qt.Key_Plus) { zoom(true) event.accepted = true } } } Since control + + and control + - are standard shortcuts for

How Start a Qthread from qml?

浪子不回头ぞ 提交于 2019-12-31 02:56:31
问题 I need to Start immediately and stop then a QThread extended class from Qml File. Is there any solution for that? here is my class : class SerialManager : public QThread { Q_OBJECT public: CircularList<unsigned char> buffer_[2]; signals: void dataReady(short *value,int len,unsigned short sample); protected: void run(); }; 回答1: if you have SerialManager like this: class SerialManager : public QThread { Q_OBJECT public: CircularList<unsigned char> buffer_[2]; signals: void dataReady(short

QML Timer - How to improve accuracy?

亡梦爱人 提交于 2019-12-31 01:48:08
问题 I'm developing a QML metronome. I used a timer with interval 60000/Beats per minute. However it isn't really accurate. How can I improve the accuracy. Should I use a Timer, or is there a better solution? 回答1: The fundamental issue with QTimer that it uses the Qt event loop for the timing. Unfortunately, it cannot be accurate enough, inherently. The latency for notifications and all that within the event loop is getting in the way. You would need to consider a timer that does not actually

How to connect a destroyed signal of C++ object from QML?

随声附和 提交于 2019-12-31 00:36:26
问题 I want to connect a destroyed signal of C++ QObject from QML so I did this: Rectangle { id: root width: 128 height: 128 Button { anchors.centerIn: parent text: "Click me" onClicked: { qobj.Component.onDestruction.connect(function(){console.log("It destroy")}) // qobj is set from c++ qobj.destroy() // should output "It destroy" } } But nothing is printed when I destroy qobj . 回答1: In the general case, you can connect to signals emitted from a C++ object using a Connections element: Connections

Android back button press doesn't trigger keys.onreleased qml

烂漫一生 提交于 2019-12-30 18:57:31
问题 I am creating a program in Qt5.3 and Qtquick2.1. I am trying to capture back button press on android in my code using Keys.onReleased. But that event is not getting triggered. Also I have set the item focus to true. But still no success. Here is the code sample import QtQuick 2.1 import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.2 import QtQuick.Layouts 1.1 import QtQuick.Window 2.1 Rectangle { id: main2 focus: true width: Screen.Width height: Screen.Height Keys.enabled: true Keys

Android back button press doesn't trigger keys.onreleased qml

核能气质少年 提交于 2019-12-30 18:57:06
问题 I am creating a program in Qt5.3 and Qtquick2.1. I am trying to capture back button press on android in my code using Keys.onReleased. But that event is not getting triggered. Also I have set the item focus to true. But still no success. Here is the code sample import QtQuick 2.1 import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.2 import QtQuick.Layouts 1.1 import QtQuick.Window 2.1 Rectangle { id: main2 focus: true width: Screen.Width height: Screen.Height Keys.enabled: true Keys

QT QML resource files do not recompile after changes

醉酒当歌 提交于 2019-12-30 18:19:28
问题 I'm using QT 5.9.1 working on Mac OS. My project is mobile App with C++ logic and QML UI Layer. All QML files are included into qml.qrc file, so in my .pro file I have RESOURCES += qml.qrc Inside qml.qrc there is a list of all resource files I use in Project, such as pictures, icons and QML files, in QT Creator it's displayed OK: As you can see some QML files are located in ROOT path of qml.qrc when other files are in subfolders , e.g. "qrc:/Elements/". So problem is that whenether I make

QT QML resource files do not recompile after changes

我怕爱的太早我们不能终老 提交于 2019-12-30 18:19:09
问题 I'm using QT 5.9.1 working on Mac OS. My project is mobile App with C++ logic and QML UI Layer. All QML files are included into qml.qrc file, so in my .pro file I have RESOURCES += qml.qrc Inside qml.qrc there is a list of all resource files I use in Project, such as pictures, icons and QML files, in QT Creator it's displayed OK: As you can see some QML files are located in ROOT path of qml.qrc when other files are in subfolders , e.g. "qrc:/Elements/". So problem is that whenether I make

Hide key from Qt Virtual keyboard

点点圈 提交于 2019-12-30 11:24:27
问题 Is there a way to hide the language selection key from the virtual keyboard without use a custom layout? 回答1: I was able to hide the language key with a workaround: property var keyboardLayout: inputPanel.keyboard.layout function findChildByProperty(parent, propertyName, propertyValue, compareCb) { var obj = null if (parent === null) return null var children = parent.children for (var i = 0; i < children.length; i++) { obj = children[i] if (obj.hasOwnProperty(propertyName)) { if (compareCb !=

forceActiveFocus() vs focus = true in QML

荒凉一梦 提交于 2019-12-30 11:14:45
问题 I read the documentation about: focus property activeFocus property forceActiveFocus() method FocusScope object and keyboard focus in QtQuick but it is still not clear when should someone use forceActiveFocus() method over setting the focus property to true or vice versa. 回答1: As the documentation states: For very simple cases simply setting the focus property is sometimes sufficient. Such a simple case would be, if the Item which gets focus: true is not enclosed by a FocusScope that might