Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Making custom button widget

    General and Desktop
    4
    5
    1412
    Loading More Posts
    • 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.
    • V
      viniltc last edited by

      Hi All,

      I need a custom button widget as shown below:

      0_1565276664225_Capture.JPG

      I need to make this as reusable throughout my project. Is there any documentation detailing procedure to make custom button widgets?

      Thank you

      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by mrjj

        Hi
        But is that not more like a QSlider ?
        And not a button?

        In any case, you would inherit from the base class you want and override virtual function or add new functions to make it do what you want. Sample is not related to slider/button. just example.

          #include <qwidget.h>
        
            class Vcr : public QWidget
            {
                Q_OBJECT
            public:
                Vcr( QWidget *parent = 0, const char *name = 0 );
                ~Vcr() {}
            signals:
                void rewind();
                void play();
                void next();
                void stop();
            };
        

        However, for such slider thingy , would it not be easier to simply make a composite widget.
        One that is made of several widgets ?

        alt text
        and then use stylesheet and images to make it look like the image.

        However, if u really want the value to show on the Sliders handle, then you have to subclass
        QSlider and its paintEvent, to draw the the value on top. its not possible via stylesheets.

        1 Reply Last reply Reply Quote 3
        • SGaist
          SGaist Lifetime Qt Champion last edited by SGaist

          Hi,

          Isn't that basically the same question as this thread ?

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

          V 1 Reply Last reply Reply Quote 1
          • V
            viniltc @SGaist last edited by viniltc

            @sgaist

            I'm sorry for posting it again. The idea is the same but I'm looking for a more general procedure to make a custom widget.

            I followed @mrjj comments created a button as shown below:
            0_1565338655673_Capture.JPG

            This widget contains four push buttons (for fine increment/decrement and double increment/decrement) and a label to show the current value. It is a standard form class. I need to make it as a standard widget.

            I'm still in question how to reuse it on my other forms?

            Pl45m4 1 Reply Last reply Reply Quote 0
            • Pl45m4
              Pl45m4 @viniltc last edited by

              @viniltc

              Basically there are two ways:

              • Promote
              • Build Widget

              In both cases you can use your widget in different projects (if you promote it, you have to include the source code / your widgets class)


              If debugging is the process of removing software bugs, then programming must be the process of putting them in.

              ~E. W. Dijkstra

              1 Reply Last reply Reply Quote 3
              • First post
                Last post