Making custom button widget
-
wrote on 8 Aug 2019, 15:09 last edited by
-
Lifetime Qt Championwrote on 8 Aug 2019, 15:25 last edited by mrjj 8 Aug 2019, 15:28
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 ?
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. -
Lifetime Qt Championwrote on 8 Aug 2019, 18:50 last edited by SGaist 8 Aug 2019, 18:50
Hi,
Isn't that basically the same question as this thread ?
-
Hi,
Isn't that basically the same question as this thread ?
wrote on 9 Aug 2019, 08:28 last edited by viniltc 8 Sept 2019, 08:30I'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:
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?
-
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:
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?
wrote on 9 Aug 2019, 08:36 last edited byBasically there are two ways:
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)
1/5