Am 23.08.2010 15:34, schrieb [email protected]:
> As a workaround you can rotate the Rectangle with 'rotation: 90'

Thanks, but to keep the normal anchor, height, width, etc. behavior, I 
thought I wrap a rotated Rectangle inside an Item. That way the Item 
would stile behave as expected. And while at it I though I´ll do a 
Compontent that supports left-to-right and top-to-bottom gradients.

This is the first version, that IMO should work, but does not work. If 
someone knows why, I would be happy to hear :)

---------------------------------------
import Qt 4.7

Rectangle {
     id: container
     property string gradientType: "TopToBottom"
     property Gradient gradient
     color: "gray" // for debugging later change to Item w/o color

     Rectangle {
         id: rect
         gradient: container.gradient
         anchors.fill: container // <<<< Does not work when rotated

         states: [
             State {
                 name: "TopToBottom"
                 when: container.gradientType == "TopToBottom"
                 PropertyChanges {
                     target: rect
                     rotation: 0
                 }
             },
             State {
                 name: "LeftToRight"
                 when: container.gradientType == "LeftToRight"
                 PropertyChanges {
                     target: rect
                     rotation: 270
                 }
             }
         ]
     }
}
---------------------------------------

Here is a version that works (at least for me). It´s way uglier, but well...

-----------------------------------------
import Qt 4.7

Rectangle {
     id: container
     property string gradientType: "TopToBottom"
     property Gradient gradient
     color: "gray" // for debugging later change to Item w/o color

     Rectangle {
         id: rect
         gradient: container.gradient

         states: [
             State {
                 name: "TopToBottom"
                 when: container.gradientType == "TopToBottom"
                 PropertyChanges {
                     target: rect
                     rotation: 0
                     x: 0
                     y: 0
                     width: container.width
                     height: container.height
                 }
             },
             State {
                 name: "LeftToRight"
                 when: container.gradientType == "LeftToRight"
                 PropertyChanges {
                     target: rect
                     rotation: 270
                     transformOrigin: Item.Top
                     x: - container.height / 2
                     y: container.height / 2
                     width: container.height
                     height: container.width
                 }
             }
         ]
     }
}
-----------------------------------------

Cheers,
Conny
_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-qml

Reply via email to