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. [Solved] QML LinearGradient along the x-axis
Forum Updated to NodeBB v4.3 + New Features

[Solved] QML LinearGradient along the x-axis

Scheduled Pinned Locked Moved QML and Qt Quick
12 Posts 3 Posters 4.1k Views 1 Watching
  • 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
    GoKuNiX
    wrote on last edited by
    #1

    Following the documentation of "QtGraphicalEffects":https://qt-project.org/doc/qt-5.1/qtgraphicaleffects/qml-qtgraphicaleffects1-lineargradient.html#start-prop I tried to create a gradient along the x-axis.

    At first this seems like something that is easy to do.

    When changing the value of the end-property from
    @end: Qt.point(0, 300)@
    to
    @end: Qt.point(300, 0)@
    I am still left with the same gradient along the y-axis.

    Full code:

    @
    Item {
    id: vrect
    height: 300
    width: 300

        LinearGradient {
            anchors.fill: parent
            start: Qt.point(0, 0)
            end: Qt.point(300, 0)
    
            gradient: Gradient {
                GradientStop { position: 0.0; color: "red" }
                GradientStop { position: 1.0; color: "green"}
            }
        }
    }
    

    @

    Result:

    ![URL=http://imgur.com/boNgC7R][IMG]http://i.imgur.com/boNgC7R.png[/IMG][/URL]!

    Am I missing something obvious here?

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      Your posted code works for me. Are you sure you are calling the right QML file ?

      157

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

        Yes, the code works; but it should be left to right, not top to bottom...

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          It is from Left to right.

          !http://i40.tinypic.com/296bswz.png(Result)!

          157

          1 Reply Last reply
          0
          • G Offline
            G Offline
            GoKuNiX
            wrote on last edited by
            #5

            That's weird.

            What version of Qt are you using?
            I tried with Qt 5.1.1 and 5.2 beta, both with the same result.

            1 Reply Last reply
            0
            • p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #6

              Qt 5.1.0

              157

              1 Reply Last reply
              0
              • G Offline
                G Offline
                GoKuNiX
                wrote on last edited by
                #7

                Ok,

                I forgot to reply to your earlier question about calling the correct qml file.
                I was using an empty project with the code directly in the application window, so this could not be an issue.

                Now I now for sure its not a code issue I'll try some other venues in an attempt to resolve this (different project type / different Qt version / Qt without openGL / ...)

                I'll also try on another PC since this one has some company group policies applied to it.

                I'll post my findings as soon as I have resolved this issue.

                Anyways, thank you for your help.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  GoKuNiX
                  wrote on last edited by
                  #8

                  Solved by uninstalling all versions of Qt and reïnstalled 5.2 beta1.

                  I guess something got broken while having different versions installed.

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    surfsky
                    wrote on last edited by
                    #9

                    Hello, do u solved this problem?
                    I have the same trouble, my qt version is 5.4

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      surfsky
                      wrote on last edited by
                      #10

                      Hello, do u solved this problem?
                      I have the same trouble, my qt version is 5.4

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        surfsky
                        wrote on last edited by
                        #11

                        Another question: how to insert, delete .... the Gradient.stops by javascript? I try every codes, but doesn't work T_T

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          surfsky
                          wrote on last edited by
                          #12

                          Another question: how to insert, delete .... the Gradient.stops by javascript? I try every codes, but doesn't work T_T

                          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