[Development] RFC: RAII for property changes

Marc Mutz marc.mutz at kdab.com
Wed Apr 15 16:43:50 CEST 2015


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

-- 
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt Experts



More information about the Development mailing list