qml

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 set the range of a BarCategoryAxis in a QML bar chart?

回眸只為那壹抹淺笑 提交于 2020-06-01 06:50:33
问题 I am generating data in C++ ( chartdata class) and then using it as input to QML charts ( main.qml ). However, for some reason, the BarCategoryAxis which corresponds to the AxisX is not showing the right range, therefore I only see a fraction of the categories. I have tried using min and max properties in the BarCategoryAxis object, but the categories are strings, so there is no min/max. I attach a screenshot of the window for clarity. The lower chart of the window shows the bar chart, it can

PySide2/QML populate and animate Gridview model/delegate

蓝咒 提交于 2020-05-30 08:43:19
问题 I'm newbie to QML and looking for help on below points How to filter QAbstractListModel data (Title) in Gridview model via PySide2 based on TextField input (as Regex ). How to animate delegate of Gridview on mouse hover (as showen in below image.) Here is the test code qmlHoverView.py from PySide2 import QtCore, QtQuick, QtGui, QtWidgets, QtQml import os import sys class inventoryModel(QtCore.QAbstractListModel): def __init__(self, entries, parent=None): super(inventoryModel, self).__init__

QML animations visible property changes

无人久伴 提交于 2020-05-25 06:24:06
问题 I want an animation to be painted when an element becomes visible (is should appear smoothly, not the whole at all) I tried this states: State { name: "iconOff" when: iconOnSwitch.checked == false PropertyChanges { target: selectIconRow; visible: false } } transitions: Transition { reversible: true from: "" to: "iconOff" PropertyAnimation { properties: "x,y,visible" easing.type: Easing.InOutQuad from: selectIconRow property: "visible" } } But the selectIconRow still appears immediately How

QML animations visible property changes

柔情痞子 提交于 2020-05-25 06:23:12
问题 I want an animation to be painted when an element becomes visible (is should appear smoothly, not the whole at all) I tried this states: State { name: "iconOff" when: iconOnSwitch.checked == false PropertyChanges { target: selectIconRow; visible: false } } transitions: Transition { reversible: true from: "" to: "iconOff" PropertyAnimation { properties: "x,y,visible" easing.type: Easing.InOutQuad from: selectIconRow property: "visible" } } But the selectIconRow still appears immediately How

How to bind C++ property to QML property?

浪尽此生 提交于 2020-05-12 20:03:23
问题 So I know how to bind QML property to C++ property, so when C++ one calls notify signal, QML updates the view. Is there any way to make C++ property update when user changes something using UI? For example, I have a Combobox, and I want some C++ property to be updated when user changes value of combobox. EDIT: By C++ properties I mean Q_PROPERTY macro in QObject -derived classes. 回答1: To bind a property from an object you didn't create in QML (or was created in another context), you have to

How to bind C++ property to QML property?

寵の児 提交于 2020-05-12 20:01:23
问题 So I know how to bind QML property to C++ property, so when C++ one calls notify signal, QML updates the view. Is there any way to make C++ property update when user changes something using UI? For example, I have a Combobox, and I want some C++ property to be updated when user changes value of combobox. EDIT: By C++ properties I mean Q_PROPERTY macro in QObject -derived classes. 回答1: To bind a property from an object you didn't create in QML (or was created in another context), you have to

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>

How to modify a QML Text from C++

时间秒杀一切 提交于 2020-05-08 14:49:15
问题 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>

How to add color on specific words on QML Text

会有一股神秘感。 提交于 2020-04-27 06:39:07
问题 Hello i would like to add different color on specific words of a string to be used in QML Text Text { text: "Blue Red Yellow Green" } I know that you can add color to the whole text, but i would like to add specific color on specific words. is this possible? and how is it achieved? 回答1: Text items can display both plain and rich text. For example you can have: Text { text: "<font color=\"#0000FF\">Blue</font> <font color=\"#FF0000\">Red</font>" } 来源: https://stackoverflow.com/questions