[Development] QProperty and library coding guide

Volker Hilsheimer volker.hilsheimer at qt.io
Thu Jul 16 19:36:27 CEST 2020

> On 16 Jul 2020, at 18:45, Thiago Macieira <thiago.macieira at intel.com> wrote:
> On Thursday, 16 July 2020 08:40:35 PDT Volker Hilsheimer wrote:
>> action->text = document->title; // still no binding
>> action->text = Qt::makePropertyBinding(document->title); // yay binding!
>> These struct-methods are either inline forwards, or implemented by moc, and
>> we need a differently named but identical struct for each property.
>> The struct has no data itself, so ideally would be of size zero.
> That didn't answer how they can share an address. Suppose I have two 
> properties of type QString called "text" and "title".
>  action->text = "foo";
>  action->title = "bar";
> Since std::is_same_v<decltype(action->text), decltype(action->title)> and 
> &action->text == &action->title, how does the code above even work?


calls QAction::_qt_property_api_text::structMemberFunction, which is implemented by moc to operate on d->text



calls QAction::_qt_property_api_title::structMemberFunction, which is implemented by moc to operate on d->title.

The structMemberFunctions are different for each property, but that doesn't increase the size of QAction instances.

The relevant macros are defined in qtmetamacros.h.


More information about the Development mailing list