On 15-4-2015 16:54, Keith Gardner wrote:
On Wed, Apr 15, 2015 at 9:38 AM Marc Mutz <marc.m...@kdab.com
<mailto:marc.m...@kdab.com>> wrote:
Hi André,
On Wednesday 15 April 2015 11:49:56 André Somers wrote:
> void MyClass::setFoo(QString value)
> {
> PropertyGuard guard(this, "foo"); //foo is the name of the
Q_PROPERTY
> Q_UNUSED(guard);
>
> m_foo = value;
> }
This is an interesting idea, though I don't think I have
encountered the
problems with which you motivate PropertyGuard.
For use in a library, though, I fear the string-based mechanism is too
inefficient. For use within QtWidgets, say, I'd suggest a
mechanism that works
on the member data directly.
Thanks,
Marc
I have actually run into the same situation and made a template class
that owns the variable. Its constructor takes an initial value and a
std::function<void (const T&)> as a callback for when the value
changes. The callback can be a lambda or a std::bind to the expected
signal. I also added overloads to allow for the templated class to
behave just like the contained type so that it can be swapped in
easily. I figured the Qt project wouldn't like the submission of the
class due to its template nature and its use of std::function but i am
willing to share it if anyone is interested.
I'd certainly be interested to seeing how you solved this, yes. Thanks!
André
_______________________________________________
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development
_______________________________________________
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development