Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Non-retangular shapes
Forum Updated to NodeBB v4.3 + New Features

Non-retangular shapes

Scheduled Pinned Locked Moved QML and Qt Quick
23 Posts 8 Posters 20.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    puelocesar
    wrote on last edited by
    #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:
    !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?

    1 Reply Last reply
    0
    • 2 Offline
      2 Offline
      2beers
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DenisKormalev
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • 2 Offline
          2 Offline
          2beers
          wrote on last edited by
          #4

          Denis, yea like I said it has limitation.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            strekazoid
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0
            • X Offline
              X Offline
              xsacha
              wrote on last edited by
              #6

              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!

              • Sacha
              1 Reply Last reply
              0
              • K Offline
                K Offline
                kamalakshantv
                wrote on last edited by
                #7

                Will going forward QML support irregular shapes.

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  puelocesar
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    puelocesar
                    wrote on last edited by
                    #9

                    My point is, it should be easier to work with non-retangular areas in Qt Quick. Will this be supported in the future?

                    1 Reply Last reply
                    0
                    • 2 Offline
                      2 Offline
                      2beers
                      wrote on last edited by
                      #10

                      [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."

                      1 Reply Last reply
                      0
                      • X Offline
                        X Offline
                        xsacha
                        wrote on last edited by
                        #11

                        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 :).

                        • Sacha
                        1 Reply Last reply
                        0
                        • B Offline
                          B Offline
                          blex
                          wrote on last edited by
                          #12

                          Have you checked the Pie menu implementation in Qt solutions: http://doc.trolltech.com/qq/qq09-qt-solutions.html


                          Oleksiy Balabay

                          1 Reply Last reply
                          0
                          • K Offline
                            K Offline
                            kamalakshantv
                            wrote on last edited by
                            #13

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

                            1 Reply Last reply
                            0
                            • X Offline
                              X Offline
                              xsacha
                              wrote on last edited by
                              #14

                              [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.

                              • Sacha
                              1 Reply Last reply
                              0
                              • B Offline
                                B Offline
                                blex
                                wrote on last edited by
                                #15

                                [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.


                                Oleksiy Balabay

                                1 Reply Last reply
                                0
                                • P Offline
                                  P Offline
                                  puelocesar
                                  wrote on last edited by
                                  #16

                                  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...

                                  1 Reply Last reply
                                  0
                                  • K Offline
                                    K Offline
                                    kamalakshantv
                                    wrote on last edited by
                                    #17

                                    [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.

                                    1 Reply Last reply
                                    0
                                    • X Offline
                                      X Offline
                                      xsacha
                                      wrote on last edited by
                                      #18

                                      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.

                                      • Sacha
                                      1 Reply Last reply
                                      0
                                      • P Offline
                                        P Offline
                                        puelocesar
                                        wrote on last edited by
                                        #19

                                        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]

                                        1 Reply Last reply
                                        0
                                        • P Offline
                                          P Offline
                                          puelocesar
                                          wrote on last edited by
                                          #20

                                          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]

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved