qml

QML: How to delete an objects created with Qt.createQmlObject?

馋奶兔 提交于 2020-08-06 11:41:18
问题 I have some objects created in QML code with Qt.createQmlObject (...) How can I delete/remove these objects? 回答1: something = Qt.createQmlObject (...); something.destroy(); 回答2: Take a look at this article: Dynamic Object Management in QML and on this part especially: Note that it is safe to call destroy() on an object within that object. Objects are not destroyed the instant destroy() is called, but are cleaned up sometime between the end of that script block and the next frame (unless you

QML Virtual keyboard Hide button not working

对着背影说爱祢 提交于 2020-08-05 12:04:15
问题 I am having a problem if I click on keyboard hide button .Following is the code : import QtQuick 2.6 import QtQuick.Window 2.2 import QtQuick.Controls 2.2 import QtQuick.VirtualKeyboard 2.2 Window { visible: true width: 600 height: 500 title: qsTr("Hello World") TextField { id: textfield anchors.bottom:(inputPanel.visible) ? inputPanel.top : parent.bottom color: "#2B2C2E" cursorVisible: activeFocus selectionColor: Qt.rgba(0.0, 0.0, 0.0, 0.15) selectedTextColor: color } InputPanel { id:

Diiference between setContextProperty and setProperty of object

风格不统一 提交于 2020-08-05 06:43:07
问题 I really confuse right now What's is the difference between QQmlApplicationEngine engine; engine.rootContext().setContextProperty("myObject",&userData); and object->setProperty("myObject", myObject) Here is the QML file ApplicationWindow { id: applicationWindow1 Item { id: propertyHolder property MyObject myObject } I had read how to use QML binding but still hasn't figure it out. Please help Thanks EDIT : ======================= I attached snippet code here ApplicationWindow { id:

Parsing JSON in QML [duplicate]

依然范特西╮ 提交于 2020-08-04 04:09:47
问题 This question already has answers here : Can I use JavaScript to get JSON data from the server inside my qt app? (3 answers) Closed 3 years ago . The relevant Qt doc should be this. But it makes no mention of QML. Yet on many places on the net I find usage of functions like JSON.parse in QML JS. Is there such a function and how do I use it? I'd just ask for a link to documentation but that's considered off-topic here. 回答1: Parsing JSON in QML is no different than parsing JSON in Javascript,

access items in different qml files

感情迁移 提交于 2020-08-03 09:12:46
问题 I have several qml files, each of them define a screen in my application. Sometimes, an action on one screen should change items on a different screen. Right now I do this through setting the property Item buttonId and then do for (var i = 0; i < buttonId.parent.children.length; i++) { buttonId.parent.children[i].state="inactive" } Is it possible to access Items/Objects in different files directly, e.g. through their id? 回答1: You cannot access objects in "different qml files" unless you have

Is it possible to apply a custom font to all elements in QML?

爱⌒轻易说出口 提交于 2020-07-23 11:07:10
问题 Like the question says, i want to know if there is a way to apply a custom font to all elements in QML like we can easily do in HTML setting the font on the tag body. I already have the font accessible in QML with: FontLoader { id: robotoRegular; source: "fonts/Roboto-Regular.ttf" } But now if i do something like ApplicationWindow { font.family:robotoRegular.name It doesn't seem to work, and probably isnt supposed to. Or is there a way? Im using Qt 5.11.2, QtQuick 2.2 回答1: Try this code:

Is it possible to apply a custom font to all elements in QML?

若如初见. 提交于 2020-07-23 11:06:50
问题 Like the question says, i want to know if there is a way to apply a custom font to all elements in QML like we can easily do in HTML setting the font on the tag body. I already have the font accessible in QML with: FontLoader { id: robotoRegular; source: "fonts/Roboto-Regular.ttf" } But now if i do something like ApplicationWindow { font.family:robotoRegular.name It doesn't seem to work, and probably isnt supposed to. Or is there a way? Im using Qt 5.11.2, QtQuick 2.2 回答1: Try this code:

How to improve graphics quality

心不动则不痛 提交于 2020-07-23 06:48:13
问题 First look at the difference: The top's been created in WPF and the bottom with Qt. All Path Data has been taken from materialdesignicons. For WPF I've taken XAML and for QtQuick SVG . For DropShadow I've specified a value for samples property BUT for svg and rotated Text there's no such property. Is this the difference between OpenGL/CL/etc. and DirectX or something else? The machine I'm working on has both Intel and NVIDIA! I want my QtQuick app to use NVIDIA to compute efficiently and

How to improve graphics quality

£可爱£侵袭症+ 提交于 2020-07-23 06:46:14
问题 First look at the difference: The top's been created in WPF and the bottom with Qt. All Path Data has been taken from materialdesignicons. For WPF I've taken XAML and for QtQuick SVG . For DropShadow I've specified a value for samples property BUT for svg and rotated Text there's no such property. Is this the difference between OpenGL/CL/etc. and DirectX or something else? The machine I'm working on has both Intel and NVIDIA! I want my QtQuick app to use NVIDIA to compute efficiently and

ToolTip.text doesn't change

℡╲_俬逩灬. 提交于 2020-07-23 06:35:19
问题 Here's the definition of my PathButton.qml : import QtQuick 2.0 import QtQuick.Shapes 1.12 import QtQuick.Controls 2.5 Item { property alias pathData: svg.path property alias toolTip: tip.text signal clicked() width: 28 height: width Shape{ transform: Scale{ xScale: 1.2; yScale: 1.2} ShapePath{ id: path fillColor: "black" PathSvg{ id: svg path: pathData } } } ToolTip{ id: tip visible: area.containsMouse } MouseArea{ id: area anchors.fill: parent onClicked: parent.clicked() hoverEnabled: true