Tony the Pony
Tony the Pony

Reputation: 41347

Qt: Are non-rectangular QWidgets allowed to overlap?

If I have multiple non-rectangular custom QWidgets (e.g. circle-shaped buttons), can I overlap them?

It seems there is no way to let Qt know which parts of the widgets are opaque, so mouse event are delivered to the correct QWidget (It looks like Qt assumes each widget occupies its bounding rectangle).

Should I turn these widgets into QGraphicsItems instead?

Upvotes: 1

Views: 899

Answers (1)

Dan Milburn
Dan Milburn

Reputation: 5718

You can give QWidgets a mask if you want them to be non-rectangular. This should work, but it's not always straightforward to create the mask region. QGraphicsItem certainly makes handling non-rectangular shapes much easier.

Upvotes: 3

Related Questions