Solved Customise buttons
-
Hi
I need to create a toggle button in qt and it should look like the below image. It should show the ON image when it is turned on and remain at this state until it is toggled again. It should show the OFF image in the off case. Please help me on this. -
@SId7117 hi, take a look at customizing a QCheckBox or QRadioButton
https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qcheckbox
https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qradiobutton
You can give them icon, that are shown depending on the state.
If you actually want animation and sliding over... that's not going to be trivial. But certainly possible, I would start with QSlider Class and build up/derive from there
-
@J-Hilk . Thanks for the reply. I have gone through the style sheet thread. i'm little bit confused with how to apply this style sheet to a radio button on the ui. could u give me an example code?? I am actually new to Qt ..
-
@SId7117
Stylesheet example:
Documentation
https://doc.qt.io/qt-5/qtwidgets-widgets-stylesheet-example.html
Actual code
https://code.qt.io/cgit/qt/qtbase.git/tree/examples/widgets/widgets/stylesheet?h=5.15also part of QtCreator, if you use that as your IDE