The bool test fails on this line because QVariant(true) == (QVariant(baz) and the old value doesn't get overwritten.

You might want to test on the type of the variant as well. i.e. new_value.userType() != priv->value.userType()