qml

ListView signals and slots for menu elements

北城以北 提交于 2019-12-20 03:26:09
问题 I'm trying to implement some sort of custom Menu with custom elements. The ultimate goal is to create some sort of popup menu with text and icons. But during creation I faced with some issues. I can show 2 primary problems: There is a strange menu element with title Hello world at the first position (looks like it's read title of application window): From time to time I'm getting errors like qrc:/BreezeQuickMenu.qml:45: TypeError: Property 'clicked' of object QQuickListView(0x1120830) is not

How to make QML TextField binding work under Android?

北城余情 提交于 2019-12-20 03:24:18
问题 I am currently trying to write a QML/C++ application for Android. Somewhere in my code, I have a class that looks like this: class MyClass : public QObject { Q_OBJECT Q_PROPERTY(QString prop READ prop WRITE setProp NOTIFY propChanged) public: explicit MyClass(QObject* a_Parent = 0); QString prop() const { return m_Prop; } void setProp(const QString& a_Value) { m_Prop = a_Value; emit propChanged(); } signals: void propChanged(); private: QString m_Prop; }; Somwhere in my QML stuff, I have an

Send object from c++ to qml. What about free memory?

故事扮演 提交于 2019-12-20 03:10:10
问题 There is a model inherited from QAbstractListModel, I use it in qml. One of the properties of this model are parameters, they are specific to the element type of this model. That is one element the parameters of this class TemperatureParam, DifrentParamType another, a third still something... How can I pass an object to qml and to be sure that the memory is freed after use? The code below now works as I need to, but it seems to me that it's not safe. Param class is so trivial: class

Raspbian QML bad performance

梦想与她 提交于 2019-12-20 02:55:06
问题 The same QML program run on Freescale/Yocto and Raspberry/Raspbian, these two test devices have almost same CPU armv7 . But the Raspbain side had very bad performance. and give this warning JIT is disabled for QML. Property bindings and animations will be very slow. Visit https://wiki.qt.io/V4 to learn about possible solutions for your platform. Even simple QML example also gives that. So to enable JIT, do I have to rebuild the Qt environment? or it's a bug of Raspbain platform. 回答1: I found

How to show on QML (Qt) from SQLite BLOB data as image?

我的未来我决定 提交于 2019-12-20 02:15:32
问题 My code is like below. Name - as TEXT field, Photo - as BLOB data class SqlQueryModel: public QSqlQueryModel { Q_OBJECT QHash<int,QByteArray> *hash; public: explicit SqlQueryModel(QObject * parent) : QSqlQueryModel(parent) { hash = new QHash<int,QByteArray>; hash->insert(Qt::UserRole, QByteArray("Name")); hash->insert(Qt::UserRole + 1, QByteArray("Photo")); } inline RoleNameHash roleNames() const { return *hash; } }; Selecting data view = new QQuickView(); QSqlQueryModel *someSqlModel = new

QML: How to reject drop action

帅比萌擦擦* 提交于 2019-12-20 02:14:54
问题 I have one DropArea and two elements. I want DropArea reject the drop event if the DropArea already got one element be dropped, the another element not allow drop into, unless the first one move out. DropArea { property bool dropped: false onDropped: { drop.accepted = !dropped; dropped = true; } onExited: dropped = false } But looks like drop.accepted not work, BTW anyway to get the objects was dropped in DropArea 回答1: You should control if the item must be dropped or not in onReleased ,

QML not taking ownership of object received from PyQt slot

≡放荡痞女 提交于 2019-12-20 01:12:31
问题 What is the correct way to call a Python function from QML that will instantiate and return an object to QML, and have QML side be responsible for the lifetime of the object? The problem I'm facing is that object gets garbage collected before it even reaches QML. Note that I don't want to keep explicit references to the object on the Python side, and according to the following quote from the documentation what I'm looking for should even be the default behavior: When data is transferred from

How to insert QML view in a QWidget

可紊 提交于 2019-12-19 11:32:22
问题 I am a beginner in QML and try to insert a QML View in QWdiget but I don't understand why it doesn't work. Here is a simple example of my qml file ( this is not the real file ): import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Window 2.2 import QtQuick.Dialogs 1.2 import QtQuick.Layouts 1.2 import QtQml.Models 2.1 ObjectModel { id: itemModel Rectangle { color: "orange" anchors.fill: parent } Rectangle { color: "orange" anchors.fill: parent } Rectangle { color: "orange" anchors

How to insert QML view in a QWidget

让人想犯罪 __ 提交于 2019-12-19 11:30:34
问题 I am a beginner in QML and try to insert a QML View in QWdiget but I don't understand why it doesn't work. Here is a simple example of my qml file ( this is not the real file ): import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Window 2.2 import QtQuick.Dialogs 1.2 import QtQuick.Layouts 1.2 import QtQml.Models 2.1 ObjectModel { id: itemModel Rectangle { color: "orange" anchors.fill: parent } Rectangle { color: "orange" anchors.fill: parent } Rectangle { color: "orange" anchors

ReferenceError in qt quick controls tabview

不问归期 提交于 2019-12-19 11:24:15
问题 I have written a QT Quick program use TabView. When I click the botton b1 which is in Tabview, the program should call show_text() and print the text of b1, but it print "ReferenceError: b1 is not defined". Any suggestion will be appreciated, thanks. import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Window 2.1 ApplicationWindow { function show_text() { console.log(b1.text) } TabView { id: tv Tab { id: tab1 Button{ id: b1 text:"b1's text" onClicked: { //console.log(b1.text) show