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
0
votes
1 answer

C++ inheritance with Qml support

I have a set of classes ClassA, ClassB, and ClassC: class ClassA : public QObject { Q_PROPERTY(int propertyA READ propertyA WRITE setPropertyA NOTIFY propertyAChanged) } class ClassB : public QObject { Q_PROPERTY(int propertyB READ…
Hyndrix
  • 4,282
  • 7
  • 41
  • 82
0
votes
2 answers

Binding instance of C++ object to QML object

I'm new to Qt, and have written a basic application which has one class which inherits from QObject and is bound to a QML file. I now want that class to contain a Vector of objects (let's say from a class Customers), which contains some data, such…
19172281
  • 237
  • 2
  • 10
0
votes
2 answers

Using an existing Q_PROPERTY to animate QGraphicsItem inheriting QObject

I have 2 classes, one MainWindow in which we draw in a QGraphicsView a circle (which intend to become a button !) created thanks to an other class. The class MyCircle inherits from QObject and QGraphicsItem since I want to make animation. My issue…
TaiZzZ
  • 53
  • 11
0
votes
2 answers

Using Q_Property to display properties

I have a GUI displaying a tree architecture as shown here. Each of those nodes are separate classes that are derived from the node above them. All of them inherit QObject for their implementation. Now I need to add a few properties to be displayed…
Michael Thomas
  • 443
  • 1
  • 4
  • 8
0
votes
1 answer

QT Q_PROPERTY error: linker command failed with exit code 1 (use -v to see invocation)

I tried to set up a property so that the value of a variable is change a function will be called: The DataExchange class: #ifndef DATAEXCHANGE_H #define DATAEXCHANGE_H #include #include class DataExchange : public QObject { …
Tairan Liu
  • 37
  • 1
  • 10
0
votes
1 answer

How to make a JSON-like QObject

In short, I want to make an JSON-like object, which is easily accessible to both QML / Qt C++ side. In QML, I can make a settings object like this: Item { id: settings property alias snapshot: snapshot QtObject { id: snapshot …
kuanyui
  • 782
  • 13
  • 23
0
votes
0 answers

Is it possible to display a property of my customer QT widget in Chinese

I want to display a property of my customer QT widget in Chinese. Is it possible? I've tried give a Chinese text to Q_PROPERTY macro as second parameter, but it leads to compile error. Q_PROPERTY(type name READ getFunction [WRITE…
ricky
  • 2,058
  • 4
  • 23
  • 49
0
votes
2 answers

Accessing Q_Properties of a class inherited from an Object that inherited from QObject

I have the following simplified setup where I'm trying to access the Q_Properties on the inherited class of a class that inherits from QObject. I can access the properties of the base class just fine but I can't find or see (while debugging) the…
Topher
  • 1,011
  • 11
  • 19
0
votes
1 answer

Use signals or Q_PROPERTY to update QML objects

I'm very frequently receiving data from a server. This data is mainly composed of numbers. Each of them is corresponding to a QML object that would need to be updated. What would be the best course of action between Q_PROPERTY and signals in order…
Grégoire Borel
  • 1,880
  • 3
  • 33
  • 55
0
votes
1 answer

qt-solutions QtPropertyBrowser: member access into incomplete type

I'm trying to compile qtpropertybrowser, which is a part of qt-solutions. I'm including it as part of SUBDIRS in a subdirs project. I ran qmake on buildlib/buildlib.pro, via Qt Creator, and then the resulting Makefile, and was greeted with this…
JesseTG
  • 2,025
  • 1
  • 24
  • 48
0
votes
1 answer

Qtilities: Custom property types for the property browsers?

I'm writing a program that requires the user to be very flexible in manipulating data on a given object. I figured I would use a property browser of some kind; Qtilities' ObjectDynamicPropertyBrowser caught my eye. However, I need to be able to add…
JesseTG
  • 2,025
  • 1
  • 24
  • 48
0
votes
1 answer

How to dynamically show/hide sub properties of personally defined Property using qt property

info: We are trying to create a property whose sub properties may be added/removed depending on the value of another sub property. An example of this could be an plant object. This object has one property which will be a drop down consisting of…
rich green
  • 1,143
  • 4
  • 13
  • 31
0
votes
1 answer

QML map binding v2

I'm complete noob in Qt, so my question may sound too stupid, but I really need help. I know C++ a little and that's it. So, my task is to write a C++ program which reads INI-alike (format is not very important) file height=20 width=15 To make it…
adontz
  • 1,428
  • 16
  • 36
0
votes
0 answers

QDataWidgetMapper ignoring inheritance

I have a model that is being displayed in a set of widgets using a QDataWidgetMapper. One such field is a QComboBox populated by a QStringList of options, but the mapping doesn't seem to work. QComboBox's user property is the currentText() function,…
Phlucious
  • 3,704
  • 28
  • 61
-1
votes
1 answer

C++ method in QML never called, still works

I am new to QML and saw this code. It works fine, but what confuses me is that the method setUsername was never called in the qml file. So my question is how this Q_PROPERTY works. Does anyone have a good explaination for this?
Simon
  • 61
  • 1
  • 7