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. Dynamically hide check next to QCheckBox widget?
Forum Updated to NodeBB v4.3 + New Features

Dynamically hide check next to QCheckBox widget?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 463 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.
  • D Offline
    D Offline
    Dan203
    wrote on last edited by
    #1

    Is there a way to dynamically hide the check portion of a QCheckBox widget so that it just looks like a regular QLabel? I have a dialog where I have a list of options. Depending on the state of other options in the dialog some options become optional. When one becomes optional I'd like to show the check mark and enable the buddy widget only if it's checked. When the same item becomes required I'd like to hide the check mark so it just looks like a plain label and always enable the buddy control.

    If I have to subclass the control and override the paint function that's fine, but can you offer some pointers on how exactly to do that? (I'm still somewhat new to Qt)

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      @Dan203 said in Dynamically hide check next to QCheckBox widget?:

      When one becomes optional I'd like to show the check mark and enable the buddy widget only if it's checked.

      I do not understand. How is the checkbox going to become checked if it is not visible to check?

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Dan203
        wrote on last edited by
        #3

        @ChrisW67 said in Dynamically hide check next to QCheckBox widget?:

        @Dan203 said in Dynamically hide check next to QCheckBox widget?:

        When one becomes optional I'd like to show the check mark and enable the buddy widget only if it's checked.

        I do not understand. How is the checkbox going to become checked if it is not visible to check?

        So when the option is required the check will be hidden and the checked state will only be controllable via code. When the option is optional the check will be shown and the user will be able to check/uncheck.

        I'm trying to create something similar to the attached, but without the property list control. Just using regular dialog controls.

        5451df71-622e-4a12-b586-e0d80ef8728b-image.png

        See how the checked items are enabled and the unchecked ones are disabled? Except in some circumstances I need to be able to dynamically switch that check off and control the enabled/disabled state only via code.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          Dan203
          wrote on last edited by
          #4

          I guess another option is a I could use a check without any text and just place it next to a regular QLabel. Then just show/hide the check as needed. I just tried it briefly in designer and that does work.

          D 1 Reply Last reply
          0
          • D Dan203

            I guess another option is a I could use a check without any text and just place it next to a regular QLabel. Then just show/hide the check as needed. I just tried it briefly in designer and that does work.

            D Offline
            D Offline
            Dan203
            wrote on last edited by
            #5

            @Dan203 said in Dynamically hide check next to QCheckBox widget?:

            I guess another option is a I could use a check without any text and just place it next to a regular QLabel. Then just show/hide the check as needed. I just tried it briefly in designer and that does work.

            Actually I was just playing with this option and it works exactly like I want. And it's easy to do via simple signals/slots. So I'm just going to go this route.

            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