qgadget

Accessing Structure inside a structure in QML

白昼怎懂夜的黑 提交于 2019-12-24 20:49:08
问题 Previously I posted a question on how to access structures in QML and got perfect answers from some awesome people and now i need to know is there any way to access structure inside a structure in QML , Following is the code : //MyNewStruct struct MyNewStruct { Q_GADGET float m_range; Q_PROPERTY(float range MEMBER m_range) }; //MyStruct struct MyStruct { Q_GADGET int m_val; QString m_name1; QString m_name2; QString m_name3; QString m_name4; MyNewStruct m_newStr; //**new Struct declaration Q

How to get human-readable event type from QEvent?

与世无争的帅哥 提交于 2019-12-01 03:24:17
I want to debug event handling code and would like to convert QEvent::Type enum's value to a human-readable string. QEvent has a Q_GADGET macro, so presumably there's a way of pulling that off? Recent versions of Qt do the right thing when outputting events to the debug stream, so the below isn't neccessary. If you get an error similar to warning C4273: 'operator <<' : inconsistent dll linkage , it means that your version of Qt already supports this without need for the code below. The Q_GADGET macro adds a QMetaObject staticMetaObject member to the class. The static metaobject's definition is

How to get human-readable event type from QEvent?

天大地大妈咪最大 提交于 2019-11-30 22:54:51
问题 I want to debug event handling code and would like to convert QEvent::Type enum's value to a human-readable string. QEvent has a Q_GADGET macro, so presumably there's a way of pulling that off? 回答1: Recent versions of Qt do the right thing when outputting events to the debug stream, so the below isn't neccessary. If you get an error similar to warning C4273: 'operator <<' : inconsistent dll linkage , it means that your version of Qt already supports this without need for the code below. The Q

Passing Q_GADGET as signal parameter from C++ to QML

无人久伴 提交于 2019-11-29 15:10:10
Can't get a property of a C++ object inside a QML code. Object is passed as a parameter to the signal. Expected that in QML, the property text of the Record object can be extracted. And the value should be abc . QML sees the object as QVariant(Record) , and its property text as undefined . Record is a value-type like QPoint , so it uses Q_GADGET declaration. hpp: #ifndef LISTENP_HPP_ #define LISTENP_HPP_ #include <QObject> #include "Record.hpp" class ListenP: public QObject { Q_OBJECT public: ListenP(); virtual ~ListenP(); void emitGotRecord(); signals: void gotRecord(Record r); }; #endif /*

Passing Q_GADGET as signal parameter from C++ to QML

喜夏-厌秋 提交于 2019-11-28 08:51:22
问题 Can't get a property of a C++ object inside a QML code. Object is passed as a parameter to the signal. Expected that in QML, the property text of the Record object can be extracted. And the value should be abc . QML sees the object as QVariant(Record) , and its property text as undefined . Record is a value-type like QPoint , so it uses Q_GADGET declaration. hpp: #ifndef LISTENP_HPP_ #define LISTENP_HPP_ #include <QObject> #include "Record.hpp" class ListenP: public QObject { Q_OBJECT public: