Non-retangular shapes
Page |
1 |
Hey guys, it’s me again.. I’m having lot’s of trouble because I’m working a lot with irregular shapes, like circles, cemi-arcs, etc. Like on this image:

Until now, I’m doing them as c++ extensions, with a custom QPainter draw, etc. Is there a better way to work with these custom shapes? Will Qt Quick handle better non retangular shapes in the future?
21 replies
Ok, to do the above picture:
Save the inside picture as pic2.png. Save the outside picture as pic1.png.
- import QtQuick 1.0
- Rectangle { // This is actually a(n Outside) Circle!
- width: 300; height: 300; radius: 300
- Image {
- width: parent.width; height: parent.height;
- source: "pic1.png"
- smooth: true
- Rectangle { // This is actually a(n Inside) Circle!
- anchors.centerIn: parent
- width: 230; height: 230; radius: 230
- Image {
- width: parent.width; height: parent.height;
- source: "pic2.png"
- smooth: true
- }
- }
- }
- }
Wahlah, i tested this QML out and it appears exactly as your above image.
You can even set up MouseArea’s that respect the circles.
As for splitting the outside circle in to three arc’s: that’s another kettle of fish!
Thanks for the replies everybody! I had that implemented already, but I didn’t like the methods to achieve that..
The image inside circle I did with a c++ extension to do the clipping:
- painter->setClipRegion(regiao);
I know I could just put a PNG image with a transparent circle inside it, but it woudn’t work for me, because I need transparent background..
The 3 arcs are 3 PNG images with transparency, and when I mouse hover then, they became orange..
But I had problems with the retangular MouseArea, because I needed the arcs to be buttons, but I had retangular mouseAreas instead. Anyway, I solved that by putting a smaller rounded mouseArea above the arcs, so as Quick doesn’t support overlapping MouseAreas, it sort of cut off the arc’s retangular mouseArea :P
My point is, it should be easier to work with non-retangular areas in Qt Quick. Will this be supported in the future?
I asked a similar question a few month ago and it seems that non-rectangular shapes have a lot of limitations. my problem was with clipping a “rounded” rectangle: here is what doc is tolding [doc.qt.nokia.com]
“Non-rectangular clipping regions are not supported for performance reasons.”
There’s a special widget in here: http://developer.qt.nokia.com/wiki/EmbeddedWidgetDemos
Source code is at the top.
At the bottom of the page, look at Qt5WayWidget. I think you could modify it to a 4 way widget. It looks to be exactly what you want.
Then you just need to put the class in to QML as a Type :).
Have you checked the Pie menu implementation in Qt solutions: http://doc.trolltech.com/qq/qq09-qt-solutions.html
Have you checked the Pie menu implementation
Which you can link to QML with a plugin like this: http://doc.qt.nokia.com/latest/declarative-tutorials-extending-chapter6-plugins.html
It’s for PieChart but just as easily PieMenu.
This is what you’ll need to do until there’s proper support for arcs and so on.
Which you can link to QML with a plugin like this: http://doc.qt.nokia.com/latest/declarative-tutorials-extending-chapter6-plugins.html
Thanks for the link.
You must log in to post a reply. Not a member yet? Register here!





