PDA

View Full Version : what would make more sense?



jajdoo
27th July 2011, 20:30
a rather general question, i hope it isn't too unrelated..
i have a class derived from QObject - i want to know when a dynamic property changes, so i added a signal

void dynamicPropertyChanged ( QByteArray name );
that i emit whenever a dynamic property changed event is caught (mainly to inform client objects):

bool polly::Element::event(QEvent *e)
{
if( e->type() == QEvent::DynamicPropertyChange )
{
e->accept();
emit dynamicPropertyChanged( static_cast<QDynamicPropertyChangeEvent*>(e)->propertyName() );
}
return true;
}
now, i have a class derived from the class that emits this signal, where i want to test the property to make sure its of the appropriate type/value.
my question is: should i do it by:
- overloading event in the derived class and respond there
- create a slot that tests the new value and connect it to the signal
?

mvuori
27th July 2011, 22:54
You should test it not in one way, but in _every_ way that you think people would use your class.

If your class is for your personal use, test it for the first use you have in mind and go from there.