Skip to content

Instantly share code, notes, and snippets.

@TheZoc
Last active January 22, 2020 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheZoc/eb17938509c5e4ec1c9c31a9674122a8 to your computer and use it in GitHub Desktop.
Save TheZoc/eb17938509c5e4ec1c9c31a9674122a8 to your computer and use it in GitHub Desktop.
Q_PROPERTY with functions (Qt Creator Snippet)
Q_PROPERTY($type$ $name$ READ $name:c$ WRITE Set$name:c$ NOTIFY $name$Changed)
$type$ $private_variable$_;
$type$ $name:c$() const { return $private_variable$_; }
void Set$name:c$(const $type$& $private_variable$)
{
if ($private_variable$_ == $private_variable$)
return;
$private_variable$_ = $private_variable$;
emit $name$Changed();
}
void $name$Changed();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment