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. Pushbutton on top of a big pushbutton

Pushbutton on top of a big pushbutton

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.6k 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
    sVirgo
    wrote on last edited by
    #1

    I have a pushbutton which has size 256, 480 and on that pushbutton I have another push button which is size of 56, 20.
    Both the buttons have slots connected to their onclick. Sometimes when I click the smaller button, it presses the top button instead of the smaller button.

    How can I make sure that both buttons don't conflict for onclick event?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      You customize the behavior of "QWidget's virtual method mousePressEvent":http://doc.qt.nokia.com/stable/qwidget.html#mousePressEvent and to check if the coordinates on the pressed point are inside the smaller button.

      http://anavi.org/

      1 Reply Last reply
      0
      • BilbonSacquetB Offline
        BilbonSacquetB Offline
        BilbonSacquet
        wrote on last edited by
        #3

        You are using a trick, because a pushbutton is not a container (he doesn't accept children, even if formally you could do it), so mainly the first one gets the messages.

        You should be sure that the inside button is coming before the big one:

        set both button on the same parent (need some layout trick to put them correctly)

        make sure that the big under the small: big.stackUnder(small);

        Another way is to work with messages (redefine in big button the mousePress() to ignore the click in small button area) but it make all more complex.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sVirgo
          wrote on last edited by
          #4

          Thank you!
          I found it that there was a overlap of some drawings of my big button on smaller button.

          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