qml

Can't call slot or Q_INVOKABLE from QML in subclass of QQmlPropertyMap

佐手、 提交于 2020-07-05 07:25:10
问题 I'm trying to test drive the QQmlPropertyMap class. It seems like it might work well for what I want, if I can subclass it. The documentation here even gives some rudimentary instructions on what to do for subclassing it. Said documentation also indicates that this class derives from QObject . For what it's worth, I'm using QtCreator 2.6.1 on Qt 5.0.0 with QtQuick 2.0. My main.qml: import QtQuick 2.0 Rectangle { width: 360 height: 360 Text { text: owner.field anchors.centerIn: parent }

Can't call slot or Q_INVOKABLE from QML in subclass of QQmlPropertyMap

ぃ、小莉子 提交于 2020-07-05 07:23:12
问题 I'm trying to test drive the QQmlPropertyMap class. It seems like it might work well for what I want, if I can subclass it. The documentation here even gives some rudimentary instructions on what to do for subclassing it. Said documentation also indicates that this class derives from QObject . For what it's worth, I'm using QtCreator 2.6.1 on Qt 5.0.0 with QtQuick 2.0. My main.qml: import QtQuick 2.0 Rectangle { width: 360 height: 360 Text { text: owner.field anchors.centerIn: parent }

Unknown type name QML_ELEMENT

别说谁变了你拦得住时间么 提交于 2020-06-28 07:59:22
问题 In the new Qt 5.15.0 there is a new declarative way to register C++ types for usage in QML. I followed the steps given in Qt Help (https://doc.qt.io/qt-5/qtqml-cppintegration-definetypes.html#registering-an-instantiable-object-type) but it givens to me the following error: /.../randomnumbergenerator.h:10: error: ‘QML_ELEMENT’ does not name a type QML_ELEMENT ^~~~~~~~~~~ The class's definition is, for the moment: #ifndef RANDOMNUMBERGENERATOR_H #define RANDOMNUMBERGENERATOR_H #include <QObject

QML : how to pass javascript function as argument in another function

一世执手 提交于 2020-06-27 08:22:10
问题 I have QML code, for example this code Item { id:self; function update(){ var visitFunc = self.applyUpdate; innerTraversal(self,visitFunc); } function reset(){ var visitFunc = self.applyReset; innerTraversal(self,visitFunc); } function innerTraversal(obj, visitFun){ console.log(typeof visitFun); if(obj!== self && visitFun && typeof visitFun ==="function") visitFun(obj); if(hasChilderns(obj)){ var objChilderns = obj.children; for(var i=0 ; i< objChilderns.length ; i++){ innerTraversal

Simple button click connection to python function

丶灬走出姿态 提交于 2020-06-23 13:06:09
问题 I have a very simple Qml/Python application with some content in a StackView(), with the first page containing a simple button. My question is, does EVERYTHING between Qml and Python work via signals only? Or can the button click fire/call a function directly from a python script? Haven't tried much, as I am not sure how to proceed from here main.qml import QtQuick 2.12 import QtQuick.Controls 2.5 import QtQuick.Layouts 1.5 import "custom/components" ApplicationWindow { visible: true width:

Simple button click connection to python function

荒凉一梦 提交于 2020-06-23 13:06:06
问题 I have a very simple Qml/Python application with some content in a StackView(), with the first page containing a simple button. My question is, does EVERYTHING between Qml and Python work via signals only? Or can the button click fire/call a function directly from a python script? Haven't tried much, as I am not sure how to proceed from here main.qml import QtQuick 2.12 import QtQuick.Controls 2.5 import QtQuick.Layouts 1.5 import "custom/components" ApplicationWindow { visible: true width:

Qt error : The program has unexpectedly finished. The process was ended forcefully

戏子无情 提交于 2020-06-17 13:33:30
问题 I Started new project with Qt5 , and tried Qt Quick Project( QML ) on Windows10(64bit). Because I want to use various animations & effects. But I hit a brick wall, that I can't run & debug QML projects. First, I want to use swiping so I try swipe example, but the project makes an error. The run error is first image, and the debug error is second image. p.s - I tried somthing to solve the errors, which are updating NVIDIA driver, trying to release mode and making a new Qt Quick Application

Qt error : The program has unexpectedly finished. The process was ended forcefully

浪尽此生 提交于 2020-06-17 13:33:25
问题 I Started new project with Qt5 , and tried Qt Quick Project( QML ) on Windows10(64bit). Because I want to use various animations & effects. But I hit a brick wall, that I can't run & debug QML projects. First, I want to use swiping so I try swipe example, but the project makes an error. The run error is first image, and the debug error is second image. p.s - I tried somthing to solve the errors, which are updating NVIDIA driver, trying to release mode and making a new Qt Quick Application

Custom QML module deployment to Android: QML dependencies missing

两盒软妹~` 提交于 2020-06-16 04:32:08
问题 Im developing a custom QML module (let's call it MyModule) containing some special types. It is used as precompiled library on other application projects (i.e. the source code is not available to them, it's used via import MyModule 1.0, setting the necessary import paths etc.). The module contains C++-bases QML types as well as QML files that themselves import QtQuick modules like QtQuick.Controls and QtQuick.Window. When I try to deploy and execute an application developed using MyModule to

Get signal from qml into c++ class in Qt

旧城冷巷雨未停 提交于 2020-06-13 06:10:27
问题 I try to figure out how to get signal from QML code and connect it to slot located in C++ class. I take code from this answer and the control shown on the screen but I can't get the signal. Here is the relevant code: test.qml: import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Layouts 1.1 Switch{ id: swt; checked:true; onCheckedChanged: swt.qmlSignal(); } menu.cpp: Menu::Menu(QWidget *parent) : QWidget(parent), ui(new Ui::Menu) { ui->setupUi(this); QQuickView *view = new QQuickView