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. Custom Designer plugin and the promote feature
Forum Updated to NodeBB v4.3 + New Features

Custom Designer plugin and the promote feature

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 1.9k Views 4 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by mrjj
    #1

    Hi
    Im testing with the world clock example
    http://doc.qt.io/qt-5/qtdesigner-worldtimeclockplugin-example.html
    and it was successfully loaded and used.

    But, its not possible to use the promote feature?

    So what do i need to do to enable it for the world plugin?
    Assuming its possible with custom plugins.? ( i really hope)
    thank you

    1 Reply Last reply
    1
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      Yeah, so according to this thread it's quite silly but doable.
      You need a widgets collection with a doubled entry for your widget. In case of the world clock example this would boil down to 2 steps:

      1. Comment this out from the WorldTimeClockPlugin class:
      Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface")
      
      1. Implement a collection class and add the widget interface twice (you can put that under the widget interface class):
      class WorldTimeClockPluginWidgets: public QObject,
                                         public QDesignerCustomWidgetCollectionInterface
       {
           Q_OBJECT
           Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetCollectionInterface")
           Q_INTERFACES(QDesignerCustomWidgetCollectionInterface)
      
       public:
           WorldTimeClockPluginWidgets(QObject *parent = nullptr) : QObject(parent)
           {
              auto widget = new WorldTimeClockPlugin();
              widgets.append(widget);
              widgets.append(widget);
           }
           QList<QDesignerCustomWidgetInterface*> customWidgets() const Q_DECL_OVERRIDE
           { return widgets; }
      
       private:
           QList<QDesignerCustomWidgetInterface*> widgets;
       };
      
      mrjjM 1 Reply Last reply
      5
      • Chris KawaC Chris Kawa

        Yeah, so according to this thread it's quite silly but doable.
        You need a widgets collection with a doubled entry for your widget. In case of the world clock example this would boil down to 2 steps:

        1. Comment this out from the WorldTimeClockPlugin class:
        Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface")
        
        1. Implement a collection class and add the widget interface twice (you can put that under the widget interface class):
        class WorldTimeClockPluginWidgets: public QObject,
                                           public QDesignerCustomWidgetCollectionInterface
         {
             Q_OBJECT
             Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetCollectionInterface")
             Q_INTERFACES(QDesignerCustomWidgetCollectionInterface)
        
         public:
             WorldTimeClockPluginWidgets(QObject *parent = nullptr) : QObject(parent)
             {
                auto widget = new WorldTimeClockPlugin();
                widgets.append(widget);
                widgets.append(widget);
             }
             QList<QDesignerCustomWidgetInterface*> customWidgets() const Q_DECL_OVERRIDE
             { return widgets; }
        
         private:
             QList<QDesignerCustomWidgetInterface*> widgets;
         };
        
        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by mrjj
        #3

        @Chris-Kawa
        Thank you!
        It works.
        Pretty strange to add twice:)

        kshegunovK 1 Reply Last reply
        0
        • mrjjM mrjj

          @Chris-Kawa
          Thank you!
          It works.
          Pretty strange to add twice:)

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @mrjj
          Forgive my ignorance, but why do you want to promote that particular widget? Isn't promoting from QWidget sufficient for most cases?

          Read and abide by the Qt Code of Conduct

          mrjjM 1 Reply Last reply
          0
          • kshegunovK kshegunov

            @mrjj
            Forgive my ignorance, but why do you want to promote that particular widget? Isn't promoting from QWidget sufficient for most cases?

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @kshegunov
            its allows me to play with a dedicated promotion widget that show image and other info.
            I could use QLabel etc but would like a custom one.

            Main reason is that a normal QWidget dont show any sign of promotion.
            I would like show more and/or color to provide more design
            feedback in Designer.

            kshegunovK 1 Reply Last reply
            0
            • mrjjM mrjj

              @kshegunov
              its allows me to play with a dedicated promotion widget that show image and other info.
              I could use QLabel etc but would like a custom one.

              Main reason is that a normal QWidget dont show any sign of promotion.
              I would like show more and/or color to provide more design
              feedback in Designer.

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by kshegunov
              #6

              @mrjj
              Fair enough, I was just curious. :)

              Also I believe promotion doesn't allow you to fiddle with the properties, so you'd like to be as close as possible to the end-result widget ...

              Read and abide by the Qt Code of Conduct

              mrjjM 1 Reply Last reply
              0
              • kshegunovK kshegunov

                @mrjj
                Fair enough, I was just curious. :)

                Also I believe promotion doesn't allow you to fiddle with the properties, so you'd like to be as close as possible to the end-result widget ...

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @kshegunov
                its not so much to be able to set properties design time.
                More for the visual feedback while layout out the GUI.
                It seems that dynamic properties carry over so
                that could also be used for design time
                adjustment.
                Its just a research project. Might be lame idea.

                But I needed to be able to promote to even be possible.

                Ill let u know if it was it fact pointless or it did provide benefits.
                I still need to test if a custom widget can get the other widget on the form at design time.
                That would open up for interesting stuff. :)

                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