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. QML Diagonal Gradient in an Rectangle
QtWS25 Last Chance

QML Diagonal Gradient in an Rectangle

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 5.6k Views
  • 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.
  • G Offline
    G Offline
    gronerth
    wrote on last edited by
    #1

    Does anybody know how to achieve a gradient in a rectangle from topRight to BottomLeft (Diagonal Gradient)? or the only way is through an image (without c++)?..

    Thanks!


    JETG

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

      The only way that I know of is to use 2 rectangles and set the parent to clip and have
      the child be your gradient and then rotate the child.

      !http://i52.tinypic.com/2vx0t46.png!

      @
      Rectangle {
      width: 100
      height: 100
      clip: true

          Rectangle {
              x: -17
              y: -18
              width: 135
              height: 137
              rotation: 123
              gradient: Gradient {
                  GradientStop {
                      position: 0
                      color: "#ffffff"
                  }
                  
                  GradientStop {
                      position: 1
                      color: "#000000"
                  }
              }
          }
      }
      

      @

      You could also try qmlcanvas -> http://qt.gitorious.org/qt-labs/qmlcanvas

      1 Reply Last reply
      0
      • G Offline
        G Offline
        gronerth
        wrote on last edited by
        #3

        Really thanks again!


        JETG

        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