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 Widget Plug-in for Qt designer.
Forum Updated to NodeBB v4.3 + New Features

Custom Widget Plug-in for Qt designer.

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 3 Posters 2.9k 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.
  • RatzzR Offline
    RatzzR Offline
    Ratzz
    wrote on last edited by Ratzz
    #2

    Have you referred this ?
    and this example http://doc.qt.io/qt-5/qtdesigner-customwidgetplugin-example.html
    or this https://techbase.kde.org/Development/Tutorials/Writing_Qt_Designer_Plugins

    --Alles ist gut.

    A 1 Reply Last reply
    3
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #3

      Hi
      If you custom widget do not need new properties to be edited or full integration, there
      is also the "Promote" feature that let you use a custom widget in Designer without all the plugin code.

      http://doc.qt.io/qt-5/designer-using-custom-widgets.html

      A 1 Reply Last reply
      3
      • RatzzR Ratzz

        Have you referred this ?
        and this example http://doc.qt.io/qt-5/qtdesigner-customwidgetplugin-example.html
        or this https://techbase.kde.org/Development/Tutorials/Writing_Qt_Designer_Plugins

        A Offline
        A Offline
        amitgolhani
        wrote on last edited by
        #4

        Thanks a lot Ratzz

        But I have used your way. I have prepared all my custom widgets according to your suggestions.
        May you clarify my query please :
        Is each custom (or) standard widget prepared with the help of QPainter object?

        1 Reply Last reply
        0
        • mrjjM mrjj

          Hi
          If you custom widget do not need new properties to be edited or full integration, there
          is also the "Promote" feature that let you use a custom widget in Designer without all the plugin code.

          http://doc.qt.io/qt-5/designer-using-custom-widgets.html

          A Offline
          A Offline
          amitgolhani
          wrote on last edited by
          #5

          @mrjj

          Thanks Mrjj

          But my custom widget must have full integration.
          Is there another way?
          :)

          mrjjM 1 Reply Last reply
          0
          • A amitgolhani

            @mrjj

            Thanks Mrjj

            But my custom widget must have full integration.
            Is there another way?
            :)

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

            @amitgolhani
            Hi
            Nope that is the way.
            Only note is that if you have mutiple custom widgets then
            http://doc.qt.io/qt-5/qdesignercustomwidgetcollectioninterface.html
            might be handy.

            A 1 Reply Last reply
            2
            • mrjjM mrjj

              @amitgolhani
              Hi
              Nope that is the way.
              Only note is that if you have mutiple custom widgets then
              http://doc.qt.io/qt-5/qdesignercustomwidgetcollectioninterface.html
              might be handy.

              A Offline
              A Offline
              amitgolhani
              wrote on last edited by
              #7

              @mrjj

              Thanx mrjj. I have tried this.

              Please give me one more solution. I draw my custom widget with the help of Qt C++. And I am using QPainter object to draw my custom widget (Like painter.drawEllipse() ). Can I draw my custom widget another way?

              Actually I am not applying stylesheet into QPainter object. Style sheets for custom widget like background color, border-color, gradient etc.

              Thanx

              mrjjM 1 Reply Last reply
              0
              • A amitgolhani

                @mrjj

                Thanx mrjj. I have tried this.

                Please give me one more solution. I draw my custom widget with the help of Qt C++. And I am using QPainter object to draw my custom widget (Like painter.drawEllipse() ). Can I draw my custom widget another way?

                Actually I am not applying stylesheet into QPainter object. Style sheets for custom widget like background color, border-color, gradient etc.

                Thanx

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

                @amitgolhani
                Hi
                All widgets draw themself with painter.
                Instead of using painter calls (like drawEllipse) you can use an image.
                Otherwise using painter is how widgets draw themself.
                Often using styles

                void MyWidget::paintEvent(QPaintEvent *event)
                {
                    QPainter painter(this);
                    ...
                
                    QStyleOptionFocusRect option(1);
                    option.init(this);
                    option.backgroundColor = palette().color(QPalette::Window);
                
                    style().drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter,
                                          this);
                }
                
                A 1 Reply Last reply
                2
                • mrjjM mrjj

                  @amitgolhani
                  Hi
                  All widgets draw themself with painter.
                  Instead of using painter calls (like drawEllipse) you can use an image.
                  Otherwise using painter is how widgets draw themself.
                  Often using styles

                  void MyWidget::paintEvent(QPaintEvent *event)
                  {
                      QPainter painter(this);
                      ...
                  
                      QStyleOptionFocusRect option(1);
                      option.init(this);
                      option.backgroundColor = palette().color(QPalette::Window);
                  
                      style().drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter,
                                            this);
                  }
                  
                  A Offline
                  A Offline
                  amitgolhani
                  wrote on last edited by
                  #9

                  @mrjj

                  Actually I am using painter.drawEllipse() call to draw an ellipse. How do I apply style only inside ellipse area?
                  You can see in the below image-

                  alt text

                  Thanx

                  mrjjM 1 Reply Last reply
                  0
                  • A amitgolhani

                    @mrjj

                    Actually I am using painter.drawEllipse() call to draw an ellipse. How do I apply style only inside ellipse area?
                    You can see in the below image-

                    alt text

                    Thanx

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

                    @amitgolhani
                    Hi, please use external site for image.
                    Pictures are broken here and we cant see.

                    • How do I apply style only inside ellipse area
                      What style ? Its not clear what you mean.
                    A 1 Reply Last reply
                    0
                    • mrjjM mrjj

                      @amitgolhani
                      Hi, please use external site for image.
                      Pictures are broken here and we cant see.

                      • How do I apply style only inside ellipse area
                        What style ? Its not clear what you mean.
                      A Offline
                      A Offline
                      amitgolhani
                      wrote on last edited by
                      #11

                      @mrjj

                      Hi Mrjj,

                      Actually I prepared an ellipse custom widget. I integrated it into qt designer. I want to apply styleSheet from property editor of qt designer.
                      I want to apply all styleSheet only inside ellipse widget not for whole selected widget in the qt designer.
                      How will I achieve the same?

                      NOTE:
                      Style-sheet like background-color, border-color, gradient ,background picture etc. etc.

                      alt text

                      1 Reply Last reply
                      0
                      • mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by mrjj
                        #12

                        Hi
                        The things you set in stylesheet is used via QStyle style()->drawControl

                        Like

                        http://stackoverflow.com/questions/11901037/how-to-render-a-red-push-button-using-qstyle-drawcontrol

                        class Widget : public QWidget
                        {
                          // To allow the automatic deletion without parenting it
                          QScopedPointer<QPushButton> button;
                        public:
                            Widget() : button(new QPushButton) {
                              button->setStyleSheet("background-color: red");
                            }
                            virtual void paintEvent(QPaintEvent* event)
                            {
                                QStyleOptionButton opt;
                                opt.state = QStyle::State_Active | QStyle::State_Enabled;
                                opt.rect = QRect(50, 25, 100, 50);
                                QPainter painter(this);
                                button->style()->drawControl(QStyle::CE_PushButton, &opt, &painter, 
                                                             button.data());
                            }
                        };
                        

                        Sadly there is no direct Style for an ellipse so unless you can you can find a Control look to res-use ( a QStyleOptionXXX),
                        then you have to draw it all by hand.

                        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