Triangle button - Geometry
-
If created my custom buttons (inhereting from QPushButton). I've redefined the paintEvent to draw a triangle
Now I have put the buttons next to each other, as shown here: "http://i54.tinypic.com/2z81efa.png":http://i54.tinypic.com/2z81efa.pngMy problem now is that I want to create a bunch of functions for clicked() mouseOver(), etc..
But since the only way of doing this is to call the setGeometry() of the button and setGeometry() only takes a rectangle, the two buttons' geometry overlap.
This means when my mouse moves over button2, the mouseOver() event never occurs since button1's geometry overlaps with with button2's geometry.I don't think it is possible to setGeomtry() with a polygon, or is it?
Is there maybe any other way to accomplish this (that each triangle button can receive their own event in this position and form)? -
Geometry on widgets is always a rectangle.
You maybe could go with "QGraphicsView":http://doc.trolltech.com/4.7-snapshot/qgraphicsview.html and "QGraphicsItem":http://doc.trolltech.com/4.7-snapshot/qgraphicsitem.html which happens to support a "shape()":http://doc.trolltech.com/4.7-snapshot/qgraphicsitem.html#shape
Or you create your own QWidget derived class, do the painting (which you already implemented) and handle the mouse events yourself. In that way you would have two buttons in one widget. Don't know if that would be of any use for you...
-
Thanks, I will look at QGraphicsView.
The second option you mentioned wouldn't work so well, my buttons can actually be any shape/polygon in any position