Qt Forum

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

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

    General and Desktop
    3
    4
    412
    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.
    • Excludos
      Excludos last edited by 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 1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

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

        1 Reply Last reply Reply Quote 4
        • mrjj
          mrjj Lifetime Qt Champion last edited by

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

          1 Reply Last reply Reply Quote 4
          • K
            koahnig @Excludos last edited by

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

            Excludos 1 Reply Last reply Reply Quote 1
            • Excludos
              Excludos @koahnig last edited by Excludos

              @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 Reply Quote 0
              • First post
                Last post