Skip to content

Commit 6d3932a

Browse files
authored
Update README.md
1 parent 938ca67 commit 6d3932a

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*forked from [Rolias/PropertyHelper.h](https://gist.github.com/Rolias/48d453a0490d36090193)*
1+
*modified from [Rolias/PropertyHelper.h](https://gist.github.com/Rolias/48d453a0490d36090193)*
22

33
# Overview
44
These macros are intended to reduce the amount of boilerplate code the user has to write when using the Qt Frameworks's Q_PROPERTY feature. The idea was to provide something similar to C#'s auto property feature.
@@ -30,15 +30,29 @@ READONLY_PROPERTY(TYPE, NAME)
3030
will create a standard
3131
3232
```c
33-
Q_PROPERTY( TYPE NAME READ NAME CONST)
33+
Q_PROPERTY(TYPE NAME READ NAME CONST)
3434
```
3535

36-
It will create the getter and the member variable name. It also creates a **private** setter function. The function is just named NAME, i.e. it doesn't use a set prefix. In this macro, the member variable again uses `a_` but the user is expected to initialize this variable directly. All reads of the variable should be done through the property for consistency.
36+
It will create the getter and the member variable name. In this macro, the member variable again uses `a_` but the user is expected to initialize this variable directly. All reads of the variable should be done through the property for consistency.
37+
38+
## The Third Macro
39+
```c
40+
READ_PROPERTY(TYPE, NAME)
41+
```
42+
43+
will create a standard
44+
45+
```c
46+
Q_PROPERTY(TYPE NAME READ NAME NOTIFY NAMEChanged)
47+
```
48+
49+
It like the `READONLY_PROPERTY` but the variable can be `WRITE` the new value only in C++ code.
3750

3851
## Example Usages
3952
```c
4053
AUTO_PROPERTY(QString, myProperty)
4154
READONLY_PROPERTY(double, myValueProp)
55+
READ_PROPERTY(double, myValueProp)
4256
```
4357
4458
## Usage Notes

0 commit comments

Comments
 (0)