Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Is there a way to give promoted widgets properties in designer?
Forum Updated to NodeBB v4.3 + New Features

Is there a way to give promoted widgets properties in designer?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 1.3k 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.
  • K Offline
    K Offline
    KidTrent
    wrote on last edited by
    #1

    I've created a basic QTextEdit widget and promoted it to a custom version of QTextEdit (CustomTextEdit).

    I'm okay with the visual updates not being available in Qt Designer, but I would ideally be able to set custom properties using Q_PROPERTY or something that Qt Designer allows me to adjust when it inherits from my custom CustomTextEdit class.

    I tried adding a Q_PROPERTY but it had not effect.

    Q_PROPERTY(QString fileName MEMBER m_file_name);
    Q_PROPERTY(QString sectionName MEMBER m_section_name);
    

    Is there a way to make these properties available to Qt Designer or must I implement the Widget as a Custom Widget instead of a promoted one to achieve this?

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      You need to create a designer plugin.
      Setting the property as dynamic property should work too.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      JonBJ K 2 Replies Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        You need to create a designer plugin.
        Setting the property as dynamic property should work too.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #3

        @Christian-Ehrlicher
        I have never done any of this Designer custom widget stuff --- too scary :) Do you mean setting as a dynamic property with promotion avoids having to create a Designer plugin?

        1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @JonB said in Is there a way to give promoted widgets properties in designer?:

          avoids having to create a Designer plugin?

          Simply try it out. But you have to know your properties by yourself while a simple designer plugin will provide them directly.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1
          • Christian EhrlicherC Christian Ehrlicher

            You need to create a designer plugin.
            Setting the property as dynamic property should work too.

            K Offline
            K Offline
            KidTrent
            wrote on last edited by KidTrent
            #5

            @Christian-Ehrlicher Darn, I was hoping that wasn't the case. A dynamic property wouldn't be good in this situation because it's a property that I wanted automatically added to every widget derived of my class. Thanks for the response once again!

            @JonB I guess if you're okay with creating a dynamic property every time you promote the widget manually... in that case probably. It's not as scary as you would think...

            I did it for the first time yesterday and my notes were:

            • It was a little finicky when it comes to finding the Plugins folder for designer... (I have to do it manually as it inserts it into the wrong directory).
            • There should be better documentation that outlines the process using the Wizard and follows through to use of the plugin in external projects.
            • The process could be much easier and more automated by Qt... For example when adding a custom widget using the designer to another project, Qt could/should automatically copy/move the .dll, .h, and .lib files and update the projects .pro file to have the required files included/loaded. This threw me off for probably an hour. Not sure why they haven't done this.
            1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #6

              Hi
              Just as a note for this

              • that I wanted automatically added to every widget derived of my class.

              You can also set up a promoted widget with all dynamic properties you want.
              Then Drag it to back to the WidgetList so its shown in scratchpad.

              Then you can use this as a template with all dynamic properties already added.
              Simply drag it back into a from. Also works across projects if it also has the promoted widget included.

              alt text

              Make sure you hit a white empty area when dragging so it goes to scratchpad.

              1 Reply Last reply
              1

              • Login

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