qml

QML get the winId of a loaded qml window

落花浮王杯 提交于 2020-01-04 05:44:10
问题 I would like to get the winId of a qml window. I have the following files. main.qml : import QtQuick 2.5 import QtQuick.Window 2.2 import QtQuick.Controls 1.4 Window { id: myMainWindow title: "MyMainWindow" width: 200 height: 200; visible: true Component.onCompleted: { x = 40 y = 40 } } and my main.cpp : #include <QGuiApplication> #include <QQmlApplicationEngine> #include <QWindow> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine;

QML/C++ model - view separation: data in C++, multiple lists displaying this data in QML

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-04 05:20:10
问题 I am trying to strictly separate the data (in C++) from the visualization (lists in QML). On the model side, data is stored in instances of a C++ class (Data.cpp) and pointers to that instances are arranged in two lists (completeList and selectedList) by another C++ class (Parser.cpp). Those two lists should be displayed in QML, with the following restrictions: the data in completeList is displayed in different QML ListViews (for example according to the name) this separation must be done in

PyQt QML error console missing

倾然丶 夕夏残阳落幕 提交于 2020-01-04 04:09:26
问题 The title says pretty much everything. Lets say I have this simple application: main.py >>> import sys from PyQt5.QtCore import QUrl from PyQt5.QtWidgets import QApplication from PyQt5.QtQuick import QQuickView # Main Function if __name__ == '__main__': # Create main app myApp = QApplication(sys.argv) # Create a label and set its properties appLabel = QQuickView() appLabel.setSource(QUrl('main.qml')) # Show the Label appLabel.show() # Execute the Application and Exit myApp.exec_() sys.exit()

Set Loader item property

孤街浪徒 提交于 2020-01-04 02:04:09
问题 In the context of a file manager, I have a TableView component saved in the file dirview.qml , which displays the content of some directory using FolderListModel : import QtQuick 2.4 import QtQuick.Controls 1.4 import Qt.labs.folderlistmodel 2.1 TableView { id: tableView property string folder_url: "file:///tmp" anchors.fill: parent TableViewColumn { role: "fileName" title: qsTr("Name") width: tableView.width * 0.7 } TableViewColumn { role: "fileURL" title: qsTr("Size") width: tableView.width

My QSqlQueryModel doesn't show data in the listview

霸气de小男生 提交于 2020-01-03 18:48:30
问题 I was playing around with QSqlQueryModel but I am completely stuck right now. I've searched for a solution the entire day but no luck so far. What I do got working is that it pulls data from my sqlite database BUT for some reason I can not show it in my listview. It looks like my rolenames do not exist. I get messages like....ReferenceError: id is not defined..... for each row that I pull out of the database. I've used an example from: http://qt-project.org/wiki/How_to_use_a_QSqlQueryModel_in

Generate KeyEvent from QML

那年仲夏 提交于 2020-01-03 18:28:11
问题 How can I generate a KeyEvent? I have to show functionality on Keys.onPressed & events generated from my virtual keyboard. So can I fake generate key Events when my Virtual Keyboard events are generated? I could only find how to sendKeyEvents to QML from Qt, but I want to signal it from QML. 回答1: You can't directly in QML. What you can do is expose to your QML Virtual keyboard a custom Qt object that emits key signals when you want (e.g. by calling a method YourCustomKeySignalGenerator:

Passing a python list of objects to qml

你。 提交于 2020-01-03 15:36:31
问题 I am trying to pass a list of objects from python to qml. on the qml side, I will interpret this information and using repeater and listmodel element, display these information in a table like manner. if i simply pass an object or a list of integers, i could read the information on the qml side. but otherwise when trying to pass a list of objects. how can i read a list of objects on the qml side? do i have to use different properties? below is what i have so far: class File(QObject): def _

QML doesn't show svg images

半世苍凉 提交于 2020-01-03 15:35:01
问题 I wrote a simple QML ui that is using some svg images. When I execute the app on my desktop everything is fine, the UI is shown and also the svg images on it. The problem happens when I try to execute the app on an embedded device (running windows embedded). In this case the UI is displayed but the svg images are not shown and on the console I'm getting the following message: QML BorderImage: Invalid image data: my_image.svg The png images are shown correctly instead. I research the problem

How can I intercept and cancel the minimizing of a Window?

人走茶凉 提交于 2020-01-03 07:00:09
问题 I have a Window subclass in my project, and at runtime the instance is created and shown entirely on the QML side. I know that I can prevent the window from being minimized by not including the WindowMinimizeButtonHint in the flags: , but I actually need to have the minimize button present and enabled but be able to intercept the minimize button click, cancel the actual minimizing, and do something else (FYI my client is requiring this non-standard windowing behavior, not me). So far, the

Linking QML to C++ - or should I?

六月ゝ 毕业季﹏ 提交于 2020-01-03 05:53:05
问题 I'm creating my first program with Qt (as was recommended by SO members in an earlier question). In its documentation, the Qt community encourages the use of QML as a markup language and JavaScript to handle logic. Sounds promising, but the docs lack a good beginner's explanation of how and when those two would tie in with C++. From the Qt 5 docs: While it is possible to use C++ to access and manipulate QML objects deep into the object tree, we recommend that you do not take this approach