0

I need to apply Linear Gradient along x-axis in my project. But it doesn't seem to work. Even with the simplest code, that is from Qt documentation of Linear Gradient right away, it doesn't show the expected output.

Here's my code.

ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Item {
      width: 300
      height: 300

      LinearGradient {
          anchors.fill: parent

          end: Qt.point(300, 0)
          start: Qt.point(0, 0)

          gradient: Gradient {
              GradientStop { position: 0.0; color: "white" }
              GradientStop { position: 1.0; color: "black" }
          }
      }
}}

My code produces this output.

Anyone has any idea about what's going on. Please help. Thanks in advance.

Farhan Haider
  • 1,244
  • 1
  • 13
  • 22

1 Answers1

1

It's weird, I'm using 2.5 version and I have the correct output... Anyway, you still can define your gradient vertically and apply a rotation

end: Qt.point(0, 300)
start: Qt.point(0, 0)
rotation: -90
lolo
  • 706
  • 6
  • 19
  • If you do so, I think it is recommended not to use the LinearGradient from the QtGraphicalEffects but the built-in Gradient from QtQuick. As far as I remember, the QtGraphicalEffects are not the things with the highest performance. – derM - not here for BOT dreams Oct 14 '16 at 09:50
  • Is it possible that the problem is with the GPU? I don't have a high GPU. However all other examples from QtGraphicalEffects are working properly. – Farhan Haider Oct 14 '16 at 11:48