Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. How can I set the visibility of widget properties in QtDesigner?
Forum Updated to NodeBB v4.3 + New Features

How can I set the visibility of widget properties in QtDesigner?

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
3 Posts 2 Posters 5.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • stewartS Offline
    stewartS Offline
    stewart
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      AFAIK, that's not something possible. The designable attribute is not something dynamic.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • stewartS Offline
        stewartS Offline
        stewart
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved