Unsolved Creating a random shape in QCustomWidgets
-
it may sound a bit stupid but Is it possible to create a random shaped widget which could act like a button or label or a QListWidget ?
for example I want to create a maple leaf which I want to use to display a few items and when I click on them it should do something . So is it possible ! -
Hi
Well to some degree yes.
You can use
http://doc.qt.io/qt-5/qwidget.html#setMask-1
To clip it to a shape and use paintEvent to paint the
image of said shape.
A Label would be easy as it just draws some texts, but
something like QListWidget would require more work but depending on
what you are after, maybe a background image can get something like that.If you just want a leaf looking button, you can use use image and
it just works. However, the bounding rect will be square and still trigger when you
click outside of the leaf image but still inside its clientrect. -
for completent what @mrjj said about custom widget:
Shaped clock Qt Example - http://doc.qt.io/qt-5/qtwidgets-widgets-shapedclock-example.html -
thanks @mrjj what an effort you've put . I have set the image as you've suggested. Thanks a million.
And thank you @KillerSmath