I have a few custom widget that I promote from QWidget
or QFrame
, but I would like the constructor to be able to set a list of properties to fixed, and not have to change it in Qt Desigenr property list each time I add a one of these custom wdigets, for example in my CustomWidget
class constructor :
this->setFrameShape(QFrame::NoFrame);
The problem is that those properties are applied after the constructor call in the generated ui.h file, which is generated from the designer's property list, e.g. for a default custom widget implementing QFrame
:
frame = new CustomWidget(groupBox_17);
frame->setObjectName(QStringLiteral("frame"));
frame->setGeometry(QRect(40, 170, 101, 21));
frame->setFrameShape(QFrame::StyledPanel);
frame->setFrameShadow(QFrame::Raised);
Here, we can see that the setFrameShape
called in the generated file will override the setFrameShape
in the custom widget's constructor since it is called afterwards.
So the only options I would see would be to call a method after the ui setup (which calls the generated ui.h file and therefore the setters) to change those properties like so :
ui->setupUi(this);
setComponentsProperties(); //Do my property changes here
Any idea to prevent the FrameShape
property from CustomWidget
from being overriden by the default property of QFrame
set in Qt Designer, since I do not want to have to set this property by hand on every widget I will promote?