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. Customise buttons
Qt 6.11 is out! See what's new in the release blog

Customise buttons

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 703 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.
  • S Offline
    S Offline
    SId7117
    wrote on last edited by
    #1

    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.

    on.png off.png

    J.HilkJ 1 Reply Last reply
    0
    • S SId7117

      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.

      on.png off.png

      J.HilkJ Online
      J.HilkJ Online
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @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


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      S 1 Reply Last reply
      3
      • J.HilkJ J.Hilk

        @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

        S Offline
        S Offline
        SId7117
        wrote on last edited by
        #3

        @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 ..

        J.HilkJ 1 Reply Last reply
        0
        • S SId7117

          @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 ..

          J.HilkJ Online
          J.HilkJ Online
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @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.15

          also part of QtCreator, if you use that as your IDE


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          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