Results 1 to 3 of 3

Thread: how to draw a circle using qml

  1. #1
    Join Date
    Apr 2011
    Posts
    36
    Thanks
    3
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default how to draw a circle using qml

    hi,

    i want to draw a circle or ellipse using qml.is it possible to draw?
    i saw samegame example in that they took .png to balloons.but in my app,i want to draw so that i can add text to middle of balloon.

    thanks in advance.


    hema.

  2. #2
    Join Date
    Nov 2010
    Posts
    315
    Thanked 53 Times in 51 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: how to draw a circle using qml

    Circle is simple:
    Qt Code:
    1. Rectangle {
    2. width: parent.width<parent.height?parent.width:parent.height
    3. height: width
    4. color: "red"
    5. border.color: "black"
    6. border.width: 1
    7. radius: width*0.5
    8. Text {
    9. anchor.fill = parent
    10. color: "red"
    11. text: "Boom"
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 
    Ellipse may be more tricky.
    Note that you can use graphics (like in samegame example) and text on top of it (like in my example above).

  3. The following user says thank you to MarekR22 for this useful post:

    hema (1st August 2011)

  4. #3
    Join Date
    Aug 2016
    Posts
    1
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Android

    Default Re: how to draw a circle using qml

    Ya it is possible. For example I will create a circle button.

    1. Button {
    2. x:680 (Example value)
    3. y:-150 (Example value)
    4. text: "Circle button"
    5. style: ButtonStyle {
    6. background: Rectangle {
    7. implicitWidth: 140 (Example val)
    8. implicitHeight: width
    9. border.width: control.activeFocus ? 1 : 2
    10. border.color: "white"
    11. radius: width * 0.5
    12. gradient: Gradient {
    13. GradientStop { position: 5 ; color: control.pressed ? "#eee" : "red" } (Animate)
    14. GradientStop { position: 6 ; color: control.pressed ? "#ccc" : "red" }
    15. }
    16. }
    17. }
    18. }

Similar Threads

  1. draw a circle
    By NewLegend in forum Qt Programming
    Replies: 3
    Last Post: 13th October 2010, 17:01
  2. How to draw a circle with spinbox coordinates
    By rdelgado in forum Qt Programming
    Replies: 9
    Last Post: 9th August 2010, 21:57
  3. how to draw a circle on a frame in Qt-4
    By grsandeep85 in forum Qt Programming
    Replies: 1
    Last Post: 16th September 2009, 09:05
  4. How to draw a special circle pie
    By parnedo in forum Qt Programming
    Replies: 7
    Last Post: 3rd July 2009, 16:25
  5. What is the fastest way to draw a circle ?
    By Vladimir in forum Qt Programming
    Replies: 18
    Last Post: 6th September 2007, 18:26

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.