Results 1 to 4 of 4

Thread: if there a way to use radialGradient in qml ?

  1. #1
    Join Date
    Feb 2012
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default if there a way to use radialGradient in qml ?

    zz0nt.jpg


    if i want to create the third effect , how can i do ? Thank you...

  2. #2
    Join Date
    Nov 2010
    Posts
    82
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: if there a way to use radialGradient in qml ?

    i don't think it is possible (if there's a way i'd like to know it)
    maybe you can use an image or svg with the radial in it

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: if there a way to use radialGradient in qml ?

    Quote Originally Posted by tujw2010 View Post
    if i want to create the third effect , how can i do ? Thank you...
    You don't have radial gradients anywhere here. They are all linear gradients.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Jun 2012
    Posts
    58
    Thanks
    13
    Qt products
    Qt4

    Default Re: if there a way to use radialGradient in qml ?

    For radial Gradients:
    http://qt-project.org/doc/qt-5.0/qtg...lgradient.html

    The last one looks like linear along the diagonal.

    For a square (eg., size = 10x10), you can do the following:
    <1> Construct an Item of size 10x10 and set clip = true
    <2> Imagine a square that contains this Item such that corners of the Item lie on the mid-point of the edges of this outer square. You'll have cos(45 deg) = B/H => 1/sqrt(2) = 5 / H => H = 5 * sqrt(2)
    <3> edge length of the outer square is thus 2 * 5 * sqrt(2) = 10 * sqrt(2)
    <4> make a Rectangle with anchors.centreIn: parentItem with height and width as 10 * sqrt(2)
    <5> apply linear gradient
    <6> rotate the Rectangle by 45, -45, 135 or -135 degrees, you'll have that effect.

    eg.,

    Qt Code:
    1. Item {
    2. height: 30
    3. width: 30
    4. clip: true
    5.  
    6. Rectangle {
    7. anchors.centerIn: parent
    8. height: parent.height * Math.sqrt(2)
    9. width: height
    10. gradient: Gradient {....}
    11. rotation: 45
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.