Questions tagged [qproperty]

This macro is used for declaring properties in classes that inherit QObject. Properties behave like class data members, but they have additional features accessible through the Meta-Object System.

Q_PROPERTY(type name
       (READ getFunction [WRITE setFunction] |
        MEMBER memberName [(READ getFunction | WRITE setFunction)])
       [RESET resetFunction]
       [NOTIFY notifySignal]
       [REVISION int]
       [DESIGNABLE bool]
       [SCRIPTABLE bool]
       [STORED bool]
       [USER bool]
       [CONSTANT]
       [FINAL])

The property name and type and the READ function are required. The type can be any type supported by QVariant, or it can be a user-defined type. The other items are optional, but a WRITE function is common. The attributes default to true except USER, which defaults to false.

62 questions
1
vote
0 answers

Q_PROPERTY not working properly in linux distro

i’m developing a clock application and I need to do it using Q_PROPERTY. The idea is to make all the clock control logic using C++ and deploy it in a QML GUI. I got this working on a windows machine but when I run it on a linux distro in a…
1
vote
1 answer

Adding a Custom Widget to Qt Q_PROPERTY -- or -- CustomWidgetObjectNames as a property in qt designer custom widget

CustomWidgetObjectNames = design-time objects. Q_PROPERTY(QList points READ getpoints ) QList getpoints() const { return sampleobjectlist; } private : QList
mcxxx
  • 594
  • 1
  • 8
  • 21
1
vote
2 answers

Object::property ( const char * name ) const returning empty QVariant

My class has enum property, i wish to access this property using QObject*. When calling QVariant QObject::property ( const char * name ) const return value is empty QVariant of enum type. Consider the following code: /* Interface class */ class…
krizajb
  • 1,715
  • 3
  • 30
  • 43
0
votes
1 answer

List/Get Q_PROPERTY's of derived class only

Imagine a QObject derived class: class MyObject : public QObject { Q_OBJECT; Q_PROPERTY(bool myBool READ myBool WRITE setMyBool); //... } How do I receive all the properties of the derived class MyObject only without any of the base…
Baumflaum
  • 749
  • 7
  • 20
0
votes
1 answer

Is it possible to add a Q_PROPERTY which intakes a parameter?

I have a following Q_PROPERTYs declared and of course the respective glue code for it. Q_PROPERTY(bool thisEnabled READ isThisEnabled NOTIFY thisEnabledChanged) Q_PROPERTY(bool thatEnabled READ isThatEnabled NOTIFY…
TheWaterProgrammer
  • 7,055
  • 12
  • 70
  • 159
0
votes
1 answer

I am getting an error on Qt, and can't figure out where I went wrong

So, I am learning my way around Q_PROPERTY, QMetaObject and QMetaProperty. I have built a working GUI, but whenever I run the script, I get an error Can anyone tell me what I did wrong/am doing wrong? The QDout() function, as mentioned, is only…
0
votes
0 answers

how to compile and then create lib file QtpropertBrowser

how to compile and then create lib file QtpropertBrowser. I want to add this library on my project. this library https://github.com/airpaio/QtPropertyBrowser . How can ı do. can you help me?
Mahmut
  • 7
  • 4
0
votes
1 answer

How to access Q_PROPERTY of QStringlist from Q_PROPERTY of MyClass * in qml?

I'm facing issue with the following code where I want to access a qstringlist from q_property of the class pointer containing the qstringlist. I have added all the code relevant to the problem. player.hpp This class is for players which will be…
0
votes
2 answers

How to use Q_PROPERTY with static class members

I'm new to Qt and came upon the Q_PROPERTY class, and was trying to set a static member using it. This is what I have so far: class test{ Q_OBJECT Q_PROPERTY(bool enabled READ enabled WRITE setEnabled) public: bool enabled()…
programmer
  • 27
  • 4
0
votes
2 answers

Enum property not being recognized as such

I have been trying to implement something that I believe should be pretty straightforward, but am having issues with it. In short, I have a class that has some Q_Properties, some of which I want to be namespace-level enum values. My issue is, if I…
Cobalt
  • 938
  • 9
  • 21
0
votes
0 answers

Not able to push a value from Qt to QML

I am trying to read a value from mysql db through Qt and push the value to QML(specifically to a CircularGauge dial). I am successfully able to read the db value and print it to console in Qt. When I try to expose the value to QML, it is not getting…
Gowresh R
  • 9
  • 1
0
votes
1 answer

Parsing property values from stylesheet for drawing custom widgets

I have to create a couple of custom qt widgets, some of which use custom drawing. Those widgets should be styled via the companies qt stylesheet. This creates the problem that some custom widget need to retrieve a value from stylesheet that has been…
hdmjt
  • 25
  • 3
0
votes
0 answers

Using custom type in Q_PROPERTY

I couldn't use custom type in Q_PROPERTY MEMBER. header.h class Custom { Q_GADGET Q_PROPERTY(int mode MEMBER mode STORED true) public: Custom(); int mode; }; class Test { Q_GADGET Q_PROPERTY(QString ip MEMBER ip STORED true) …
Vencat
  • 1,272
  • 11
  • 36
0
votes
2 answers

QML pointer property change signal not propagated to binding properties

I exposed a pointer variable to qml like this: Fruit: class Fruit : public QObject { Q_OBJECT Q_PROPERTY(int qualityGrade READ qualityGrade WRITE setQualityGrade NOTIFY qualityGradeChanged) Q_PROPERTY(bool organic READ organic WRITE…
S.M.Mousavi
  • 5,013
  • 7
  • 44
  • 59
0
votes
1 answer

How to update qml text from two different cpp?

I have an qml project. There is a text(named id:cnt) on StackPage.qml and I need to update this text from firstclass.cpp and secondclass.cpp. Q_PROPERTY defines are on firstclass.h and setCntText function is on firstclass.cpp. I update the text…
bladekel
  • 37
  • 7