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. LinearGradient 5.15 WHERE is the start and end property and PLEASE provide a useful example!
Forum Updated to NodeBB v4.3 + New Features

LinearGradient 5.15 WHERE is the start and end property and PLEASE provide a useful example!

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 3 Posters 326 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.
  • V Offline
    V Offline
    VFCraig
    wrote on last edited by
    #1

    LinearGradient. Initially attempted to use a RadialGradient, but let's face it, we are far enough from the sun to call it linear. Wanted buttons to have a brighter background in the upper left and darkest in the lower right. Documentation shows 2 properties that assist in accomplishing this, start and end. But when I build, and in QtCreator as well, I am informed they DO NOT EXIST!!!!!

    Add to that that the documentation tells you to set either start or end in 2 different ways, QPoint(x,y) and Qt.point(x,y). (Strikes me that "QPoint" is NOT correct, as this is QML and NOT C++, but I should expect such from QML docs by now.)

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      What docs are you reading?

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      1
      • fcarneyF Offline
        fcarneyF Offline
        fcarney
        wrote on last edited by
        #3

        Are you importing QtQuick.Shapes as well? It has a LinearGradient as well.

        import QtQuick.Shapes 1.15  
        to
        import QtQuick.Shapes 1.15 as QTSHAPES
        ...
        QTSHAPES.<items from shapes> {
        }
        example:
                    QTSHAPES.Shape {
                        anchors.fill: parent
        
                        QTSHAPES.ShapePath {
                            strokeColor: "steelblue"
                            fillColor: "transparent"
                            strokeWidth: 5
                            capStyle: ShapePath.RoundCap
        
                            startX: itemcontrol.width/2
                            startY: itemcontrol.height/2
        
                            PathAngleArc {
                                radiusX: 32
                                radiusY: 32
                                centerX: itemcontrol.width/2
                                centerY: itemcontrol.height/2
        
                                startAngle: itemcontrol.animAngle
                                sweepAngle: itemcontrol.animAngle + itemcontrol.animLength
                            }
                        }
                    }
        

        C++ is a perfectly valid school of magic.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lemons
          wrote on last edited by
          #4

          Here a simple example:

          Button {
                  id: myButton
                  height: 150
                  width: 300
                  anchors.centerIn: parent
                  text: "MyButton"
          
                  onClicked: console.debug("myButton was clicked!")
          
                  background: LinearGradient {
                      id: myGradient
                      anchors.fill: parent
          
                      property string color: "blue"
                      property double factor: 2.5
          
                      // start at (x/y) = (0/0) [top left corner]
                      // as coordinate system INSIDE THIS element
                      start: Qt.point(0, 0)
          
                      // end at (x/y) = (width/height) [bottom right corner]
                      end: Qt.point(width, height)
          
                      gradient: Gradient{
                          // begin with lighter color (brightened by myGradient.factor)
                          GradientStop {
                              position: 0.0
                              color: Qt.lighter(myGradient.color, myGradient.factor)
                          }
                          // end with darker color
                          GradientStop {
                              position: 1.0
                              color: myGradient.color
                          }
                      }
                  }
              }
          
          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