qt-quick

QML - Q_INVOKABLE functions

荒凉一梦 提交于 2021-01-27 06:51:54
问题 I have a problem with QML, with calling Q_INVOKABLE functions. Although I marked functions as Q_INVOKABLE I'm getting errors TypeError: Result of expression 'azdownloader.setData' is not a function TypeError: Result of expression 'azdownloader.perform' is not a function I have this class: typedef QString lyricsDownloaderString; class lyricsDownloader : public QObject { public: Q_INVOKABLE virtual short perform() = 0; Q_INVOKABLE inline void setData(const string & a, const string & t); // set

How to expose a C++ Model to QML

余生长醉 提交于 2021-01-20 19:51:41
问题 I'm writing a QML+Qt application . I defined a class like this : class MainClass : public QObject { Q_OBJECT public: rosterItemModel m_rosterItemModel; . . . } rosterItemModel model is a class derived from QAbstractListModel. I exposed MainClass to qml part using this function : qmlRegisterType<MainClass>("CPPIntegrate", 1, 0, "MainClass"); Now I want to assign this model(m_rosterItemModel) from MainClass to model property of a ListView in QML. I tried the following ways but none of them were

Do not repaint window during resize

一个人想着一个人 提交于 2020-08-22 05:25:17
问题 My QML application (Qt 5.4) is based on a Window item. The application can be resized by the user. When the application is resized the content of the application is being resized respectively (with onWidthChanged and onHeightChanged ). This is all fine. But to avoid flickering I don't want to update the content of the application while the applicaiton is beeing resized. Is there a possibility in QML to detect when the user is actually resizing the window (holding the mouse button down over

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:

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

Get signal from qml into c++ class in Qt

蓝咒 提交于 2020-06-13 06:10:11
问题 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

How to modify a QML Text from C++

旧时模样 提交于 2020-05-08 14:50:21
问题 I'm new to Qt and I'm trying to modify a QML Text (showed in the screen) from the C++ code. I get the text modified but it is not updated on the screen, so I have the text variable modified but the first text on the screen. Here is the code: //main.cpp #include <QApplication> #include <QDeclarativeEngine> #include <QDeclarativeComponent> #include <QDeclarativeItem> #include <QDebug> #include "qmlapplicationviewer.h" Q_DECL_EXPORT int main(int argc, char *argv[]) { QScopedPointer<QApplication>