Qt Forum

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

    Add checkbox to toolbar button

    General and Desktop
    3
    3
    2912
    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.
    • R
      rizoritis last edited by

      Hello,

      I have a custom vertical QToolBar in my application with custom buttons that I set images for. Instead of changing the image appearance for toggle buttons I would like to add a checkbox to the upper right-hand corner of each button to be checked when activated and unchecked when deactivated. I searched online to see if there were any examples or how to implement this, but came out unsuccessful. Does anyone know of a simple way to place a checkbox in the upper right corner of a button in my toolbar?

      Thanks!

      1 Reply Last reply Reply Quote 0
      • Jeroentjehome
        Jeroentjehome last edited by

        Hi, You might just need to overwrite the default paintEvent and do it your self. there is a standard "checked" for a simple checkbox in front of the button.
        Greetz

        Greetz, Jeroen

        1 Reply Last reply Reply Quote 0
        • jazzycamel
          jazzycamel last edited by

          The "Commontk":http://www.commontk.org/ widget set includes a checkable button that might be adapted to your purposes:

          !http://www.commontk.org/images/5/53/CtkCheckablePushButton.png(ctkCheckablePushButton)!

          The api is "here":http://www.commontk.org/docs/html/classctkCheckablePushButton.html and the source is "here":https://github.com/commontk/CTK/tree/master/Libs/Widgets.

          Hope this helps ;o)

          For the avoidance of doubt:

          1. All my code samples (C++ or Python) are tested before posting
          2. As of 23/03/20, my Python code is formatted to PEP-8 standards using black from the PSF (https://github.com/psf/black)
          1 Reply Last reply Reply Quote 0
          • First post
            Last post