How can I set the visibility of widget properties in QtDesigner?
-
I am creating a custom widget. My widget extends an existing widget from the Qt widget library. I would like to hide the property of the existing widget class (parent) when it is being used in QtDesigner. Can anyone suggest how I might achieve this.
I know that when I create a new widget property using the Q_PROPERTY macro that there is a DESIGNABLE attribute. This attribute is set to true by default. The attribute determines if the property should be visible in the property editor of GUI design tool. Therefore when I create a new widget using the macro I can set the DESIGNABLE attribute to false and the property is not visible in the property editor. However, what I would like to know is how to change the value of the attribute for that has already been defined in a parent class.
-
Hi and welcome to devnet,
AFAIK, that's not something possible. The designable attribute is not something dynamic.
-
Ok, thank you for the feedback. This is how it appears to me as well. Receiving clarification confirming my suspicions is very helpful.
I should explain the reason we would like to hide some properties in the QtDesigner tool is that we would like to have a consistent look and feel. Therefore by hiding properties we can ensure a more consistent behaviour with less chance of developers changing the values of properties we would do not want them to change. Of course, if they edit the code they can always find a way to change the property value.
Perhaps I will try composition instead of inheritance and then redefine the properties I want to expose to the developer in the QtDesigner tool. This will require more boilerplate code but I think it should allow me to achieve what I want.