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