I am trying to write some set of custom widget as Qt Designer plugin. Some of the properties are same for all my widgets, so I want to make a base class. But there is a problem with multiple inheritnece, when base class inherits from QObject (because of Q_PROPERTY macro to make its properties editable in Qt Designer) and the custom widget needs to be child of QWidget. But I found Qt's dynamic property so base class gets the widget pointer and sets the dynamic property.
class BaseClass {
QWidget *widget;
BaseClass(QWidget *widget) {
this->widget = widget;
this->widget->setProperty("Some", 0.0);
}
void setSome(double some) {
this->widget->setProperty("Some", some);
}
...
Thats ok. I can set the dynamic property and see them and edit them in Qt Designer, all is ok. BUT when I want to read from the property something is wrong. When I am using:
this->widget->property("Some").value<double>();
Qt Designer doesn't start (?!).
And when I use this more then once
QVariant var = this->widget->property("Some");
return var.toDouble();
It's the same problem! Qt Designer fails to start with no message or other hint. I am using Qt 4.7.4 with its designer. The same proble is in Qt Creators designer (tested on 2.0.0, 2.0.1).
Am I wrong or it is Qt's issue?
Thanks for any suggestions!