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. Making labels completely nonclickable so you can click on other widgets behind it.
Forum Update on Monday, May 27th 2025

Making labels completely nonclickable so you can click on other widgets behind it.

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 816 Views
  • 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.
  • ExcludosE Offline
    ExcludosE Offline
    Excludos
    wrote on last edited by Excludos
    #1

    I have a rather wide slider with a label stuck in the middle of it showing how much 0-100% the slider is on. The problem is that the label, even while disabled (Which is default anyways), blocks the slider from being useable. In other words if you release the slider right on the label, you're no longer able to click on it because the label is in the way.

    Slider

    I'm sure there's an easy way to fix this, but my half useless googling and searching on several qt forums has not yielded any results.

    Environment is windows 10 x64

    K 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      You can use
      setAttribute(Qt::WA_TransparentForMouseEvents);
      and dont disable it.

      1 Reply Last reply
      4
      • ExcludosE Excludos

        I have a rather wide slider with a label stuck in the middle of it showing how much 0-100% the slider is on. The problem is that the label, even while disabled (Which is default anyways), blocks the slider from being useable. In other words if you release the slider right on the label, you're no longer able to click on it because the label is in the way.

        Slider

        I'm sure there's an easy way to fix this, but my half useless googling and searching on several qt forums has not yielded any results.

        Environment is windows 10 x64

        K Offline
        K Offline
        koahnig
        wrote on last edited by
        #3

        @Excludos

        I am not sure, if I understand correctly.

        You have a label with a slider and both shall not be changable. However, you like to click something behind in the background and not visible?
        If the background item is not visble, it should be clickable. Anything else not really what you should do, because that might be anything and especially something you do not anticipate to click. You have to bring items from the background to the foreground in order to make them accessible.

        If the something in the background is also part of your single application, it is my opinion basically the same. When it is part of the slider functionality you should integrate it somehow in the slider widget you are using.

        Vote the answer(s) that helped you to solve your issue(s)

        ExcludosE 1 Reply Last reply
        1
        • K koahnig

          @Excludos

          I am not sure, if I understand correctly.

          You have a label with a slider and both shall not be changable. However, you like to click something behind in the background and not visible?
          If the background item is not visble, it should be clickable. Anything else not really what you should do, because that might be anything and especially something you do not anticipate to click. You have to bring items from the background to the foreground in order to make them accessible.

          If the something in the background is also part of your single application, it is my opinion basically the same. When it is part of the slider functionality you should integrate it somehow in the slider widget you are using.

          ExcludosE Offline
          ExcludosE Offline
          Excludos
          wrote on last edited by Excludos
          #4

          @koahnig said in Making labels completely nonclickable so you can click on other widgets behind it.:

          @Excludos

          I am not sure, if I understand correctly.

          You have a label with a slider and both shall not be changable. However, you like to click something behind in the background and not visible?
          If the background item is not visble, it should be clickable. Anything else not really what you should do, because that might be anything and especially something you do not anticipate to click. You have to bring items from the background to the foreground in order to make them accessible.

          If the something in the background is also part of your single application, it is my opinion basically the same. When it is part of the slider functionality you should integrate it somehow in the slider widget you are using.

          If you see the picture I uploaded, I have a label on top of the slider to make it very easily readable. However if I click on that part of the slider, it doesn't work because the label is in the way.

          @mrjj said in Making labels completely nonclickable so you can click on other widgets behind it.:

          Hi
          You can use
          setAttribute(Qt::WA_TransparentForMouseEvents);
          and dont disable it.

          This works perfectly! Thank you so much :)

          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