qml

Qt - How to run a C++ function when QML button is clicked? Using QQmlApplicationEngine

寵の児 提交于 2019-12-19 10:33:26
问题 myclass.h #ifndef MYCLASS_H #define MYCLASS_H #include <QDebug> #include <QObject> class MyClass : public QObject { public: MyClass(); public slots: void buttonClicked(); void buttonClicked(QString &in); }; #endif // MYCLASS_H myclass.cpp #include "myclass.h" MyClass::MyClass() { } void MyClass::buttonClicked() { // Do Something } void MyClass::buttonClicked(QString &in) { qDebug() << in; } main.cpp #include <QApplication> #include <QQmlApplicationEngine> #include <myclass.h> #include

how to insert/edit QAbstractListModel in python and qml updates automatically?

China☆狼群 提交于 2019-12-19 09:59:19
问题 i am trying to insert/edit a python list that is subclassed from QAbstractListModel in pyqt5. this python list is read in the model property of ListView element in qml. i have no issues displaying the data in qml. problem arises when i try to append new data into the python list. the following is what i have done so far: main.py: import sys, model2 from PyQt5.QtCore import QUrl from PyQt5.QtWidgets import QApplication from PyQt5.QtQuick import QQuickView class MainWindow(QQuickView): def _

QML: GridView does not update after change its model in C++

不羁岁月 提交于 2019-12-19 09:56:34
问题 My starting point is the following QML source, where GridView is showing ListModel with nice animation of item swaps: import QtQuick 1.1 GridView { id: mainGrid width: 825; height: 400; cellWidth: 165; cellHeight: 95 model: myModel delegate: myButton ListModel { id: myModel function createModel() { for (var i=1; i<=20; i++) { append({"display":i}) } } function listItems() { console.log("LIST OF ITEMS") for (var i=0; i<=19; i++) { console.log("model["+i+"]="+get(i).display) } } function

PyInstaller + PyQt5 + QML: QtQuick is not installed

女生的网名这么多〃 提交于 2019-12-19 09:06:56
问题 I'm trying to build an app using pyinstaller, PyQt5 and qml (see files below) using the following command. pyrcc5 pyqt5_qml.qrc > pyqt5_qml_qrc.py pyinstaller -w -F --noupx pyqt5_qml.py (OSX 10.11.1, python 3.5.0, qt 5.5.1, pyinstaller 3.0) The pyqt5_qml.py runs fine (open an "Hello world!" window) but the built app complains about module "QtQuick" version 2.4 is not installed . I guess the module has not been included into the built app but I'm not sure how to tell pyinstaller to do it.

Use QQmlListProperty to show and modify QList in Qml

寵の児 提交于 2019-12-19 08:13:23
问题 again, well i have a question (and maybe a problem), i make a program with qt and qml in qt5 and qml with qtquick 2.0, and i have a c++ model qlist, and i need modify the list in runtime, i use q QQmlListProperty and show the items in qml, but they are not hide and show in the moment when i add or remove my code is next: class ConceptsList: public QObject{ Q_OBJECT Q_PROPERTY(QQmlListProperty<Concept> concepts READ concepts NOTIFY conceptsChanged) Q_CLASSINFO("DefaultProperty", "concepts")

Use QQmlListProperty to show and modify QList in Qml

跟風遠走 提交于 2019-12-19 08:13:00
问题 again, well i have a question (and maybe a problem), i make a program with qt and qml in qt5 and qml with qtquick 2.0, and i have a c++ model qlist, and i need modify the list in runtime, i use q QQmlListProperty and show the items in qml, but they are not hide and show in the moment when i add or remove my code is next: class ConceptsList: public QObject{ Q_OBJECT Q_PROPERTY(QQmlListProperty<Concept> concepts READ concepts NOTIFY conceptsChanged) Q_CLASSINFO("DefaultProperty", "concepts")

QML view wont update when adding a new item to a QAbstractListModel based model

自闭症网瘾萝莉.ら 提交于 2019-12-19 08:02:14
问题 I've figured out how to bind a model derived from QAbstractListModel to a QML view. But the next thing I tired does not work. If a new Item is added to the model the QML view will not update. Why is that? DataObject.h class DataObject { public: DataObject(const QString &firstName, const QString &lastName): first(firstName), last(lastName) {} QString first; QString last; }; SimpleListModel.h class SimpleListModel : public QAbstractListModel { Q_OBJECT enum /*class*/ Roles { FIRST_NAME = Qt:

How to display correctly Treeview with QML Qt 5.5

Deadly 提交于 2019-12-19 07:35:03
问题 I'm trying to create a correct Treeview with Qml Qt 5.5. I succeed to have a Treeview with a global root. But impossible to find how to add child for row item. For the moment I got something like that : TreeView { id:listTree anchors.fill: parent anchors.leftMargin: 1 headerVisible: false backgroundVisible: false selection: ItemSelectionModel { model: myModel } TableViewColumn { role: "name" } itemDelegate: Item { Text { anchors.verticalCenter: parent.verticalCenter color: styleData.textColor

How to display correctly Treeview with QML Qt 5.5

落爺英雄遲暮 提交于 2019-12-19 07:34:52
问题 I'm trying to create a correct Treeview with Qml Qt 5.5. I succeed to have a Treeview with a global root. But impossible to find how to add child for row item. For the moment I got something like that : TreeView { id:listTree anchors.fill: parent anchors.leftMargin: 1 headerVisible: false backgroundVisible: false selection: ItemSelectionModel { model: myModel } TableViewColumn { role: "name" } itemDelegate: Item { Text { anchors.verticalCenter: parent.verticalCenter color: styleData.textColor

How to display correctly Treeview with QML Qt 5.5

二次信任 提交于 2019-12-19 07:34:26
问题 I'm trying to create a correct Treeview with Qml Qt 5.5. I succeed to have a Treeview with a global root. But impossible to find how to add child for row item. For the moment I got something like that : TreeView { id:listTree anchors.fill: parent anchors.leftMargin: 1 headerVisible: false backgroundVisible: false selection: ItemSelectionModel { model: myModel } TableViewColumn { role: "name" } itemDelegate: Item { Text { anchors.verticalCenter: parent.verticalCenter color: styleData.textColor