Non-retangular shapes



  • 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:
    !http://img816.imageshack.us/img816/7325/roundedthings.png(rounded things)!

    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?



  • well I think you can set radius to a rectangle and make it look like a circle, but it has a lot of limitations.
    probably qml canvas will help you, but is in labs stage for the moment.



  • 2beers, circled rectangle will help for center circle with photo, but not for arcs at edge.



  • Denis, yea like I said it has limitation.



  • One option those arcs can be png:s with transparency. Highlighting can be implemented by replacing a bitmap.



  • 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!



  • Will going forward QML support irregular shapes.



  • 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:

    @QRegion regiao(boundingRect().x(), boundingRect().y(), boundingRect().width(), boundingRect().height(), QRegion::Ellipse);
    painter->setClipRegion(regiao);
    painter->drawImage(boundingRect(), QImage("../ParesQml/" + imagem()));@

    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?



  • [quote author="puelocesar" date="1291289914"]My point is, it should be easier to work with non-retangular areas in Qt Quick. Will this be supported in the future?[/quote]

    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":http://doc.qt.nokia.com/4.7/qml-item.html#clip-prop

    "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



  • Hope the next release of QML supports handling such irregular shapes.



  • [quote author="blex" date="1291440045"]Have you checked the Pie menu implementation[/quote]

    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.



  • [quote author="xsacha" date="1291440435"]
    Which you can link to QML with a plugin like this: http://doc.qt.nokia.com/latest/declarative-tutorials-extending-chapter6-plugins.html[/quote]

    Thanks for the link.



  • Thanks for the tips! That's what I'm doing, creating c++ extensions to things I can't do in Qml. But I'm having serious problems in turning these extensions in plugins...



  • [quote author="puelocesar" date="1291636834"]Thanks for the tips! That's what I'm doing, creating c++ extensions to things I can't do in Qml. But I'm having serious problems in turning these extensions in plugins...[/quote]

    May be you can post the problems faced in the forums and someone might help you out.



  • You know how you need a qmlviewer C++ wrapper (well eventually)?
    You can put plugin code in there. Then you don't need to compile it separate and worry about plugins. You can just run the app and the plugin will be compiled inside the wrapper.
    The only downside is no auto complete in qml for that type.



  • It's here: https://developer.qt.nokia.com/forums/viewthread/2103/ :)

    [quote author="QtK" date="1291637122"]
    [quote author="puelocesar" date="1291636834"]Thanks for the tips! That's what I'm doing, creating c++ extensions to things I can't do in Qml. But I'm having serious problems in turning these extensions in plugins...[/quote]

    May be you can post the problems faced in the forums and someone might help you out.[/quote]



  • Yes, that's what I'm doing actually...

    But I wanted to create plugins to have a better organization between projects. Imagine 10 projects, all using a similar extension, if I wanted to change the extension, it would be MUCH easier if I had only one plugin to change and compile, get it?

    [quote author="xsacha" date="1291637394"]You know how you need a qmlviewer C++ wrapper (well eventually)?
    You can put plugin code in there. Then you don't need to compile it separate and worry about plugins. You can just run the app and the plugin will be compiled inside the wrapper.
    The only downside is no auto complete in qml for that type.[/quote]



  • Yes, as your project gets larger just move those classes out in to separate projects. Compile the plugin separately. List the plugin in your qmldir.
    I just thought it'd help you get started if just included it in the wrapper. I had problems compiling plugins too.



  • Well, I posted all my plugin code on the other thread.. Let's hope someone points out what is that stupid thing that I'm doing and how to fix it :P

    Until that, I'm using c++ extensions like you said



  • Hi,

    In the mean time; is there any improvement in supporting irregular shapes (and MouseAreas) in QtQuick?
    I can't find them.....


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.