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. Is it possible to draw polygons with QML?
Forum Updated to NodeBB v4.3 + New Features

Is it possible to draw polygons with QML?

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 4 Posters 9.6k 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.
  • T Offline
    T Offline
    trusktr
    wrote on last edited by
    #1

    For example, can I draw a triangle with QML then rotate it using QML features like Transition and State, etc?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      There is QML open-source APIs called "qmlcanvas":http://qt.gitorious.org/qt-labs/qmlcanvas that might be useful if you insist on drawing with QML. For more info check the "other articles about it at Qt Developer Network":http://qt-project.org/search/tag/qmlcanvas.

      http://anavi.org/

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lgeyer
        wrote on last edited by
        #3

        For sure.

        Either create your own QDeclarativeItem / QQuickItem in C++, use the Canvas element in QML (QtQuick 2) or pre-create your polygon in SVG.

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          ZapB
          wrote on last edited by
          #4

          Or in QtQuick2 you can also create your own custom item by inheriting from QQuickItem (draw using OpenGL) or QQuickPaintedItem (draw using QPainter).

          Nokia Certified Qt Specialist
          Interested in hearing about Qt related work

          1 Reply Last reply
          0
          • T Offline
            T Offline
            trusktr
            wrote on last edited by
            #5

            Thanks guys. I'm talking about doing it explicitly in QML so I'll definitely check out Canvas. Is it possible to embed Qt Declarative items inside QML Components (a rectangle)?

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              ZapB
              wrote on last edited by
              #6

              Yes, just make your custom item in C++, register the new type with QML and then instantiate it as a child of a rectangle in your .qml file.

              Nokia Certified Qt Specialist
              Interested in hearing about Qt related work

              1 Reply Last reply
              0
              • T Offline
                T Offline
                trusktr
                wrote on last edited by
                #7

                Wow, cool. Qt is powerful. Can't wait to have a break from school to have some extensive sessions with Qt...

                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