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. Customizing a Gradient using QML
Forum Updated to NodeBB v4.3 + New Features

Customizing a Gradient using QML

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 589 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.
  • C Offline
    C Offline
    CristianoNarcisiVidex
    wrote on last edited by
    #1

    Hi all
    i am developing a GUI that needs the gradients. The GUI has to follow some specific graphical guidelines that i could have to use for several projects. I have hence created some customization files for Button, Label and some other items. I have do the same with the Gradient: the code is thsi above:

    import QtQuick 2.0
    import QtQuick.Controls         1.4;
    import QtQuick.Controls.Styles  1.4;
    
    Gradient {  GradientStop { position: 0.0; color: "#004b87" }
                GradientStop { position: 0.75; color: "#d1d3d3" }
                GradientStop { position: 1.0; color: "#ffffff" }
              }
    
    

    The filename is BlueGradient.qml. It is stored into the Resources/qml.qrc folder. I am now trying to apply it to a Rectangle:

    Rectangle {
        property alias mouseArea: mouseArea
        property alias btn1: btn1
        property alias label1: label1
    
        width: 720
        height: 720
        gradient: BlueGradient
    

    but the Rectange keeps having the default white background.

    The debugger is showing me the following error

    qrc:/MainForm.qml:12: ReferenceError: BlueGradient is not defined
    
    ODБOïO 1 Reply Last reply
    0
    • C CristianoNarcisiVidex

      Hi all
      i am developing a GUI that needs the gradients. The GUI has to follow some specific graphical guidelines that i could have to use for several projects. I have hence created some customization files for Button, Label and some other items. I have do the same with the Gradient: the code is thsi above:

      import QtQuick 2.0
      import QtQuick.Controls         1.4;
      import QtQuick.Controls.Styles  1.4;
      
      Gradient {  GradientStop { position: 0.0; color: "#004b87" }
                  GradientStop { position: 0.75; color: "#d1d3d3" }
                  GradientStop { position: 1.0; color: "#ffffff" }
                }
      
      

      The filename is BlueGradient.qml. It is stored into the Resources/qml.qrc folder. I am now trying to apply it to a Rectangle:

      Rectangle {
          property alias mouseArea: mouseArea
          property alias btn1: btn1
          property alias label1: label1
      
          width: 720
          height: 720
          gradient: BlueGradient
      

      but the Rectange keeps having the default white background.

      The debugger is showing me the following error

      qrc:/MainForm.qml:12: ReferenceError: BlueGradient is not defined
      
      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by ODБOï
      #2

      hi,welcome to the forum!
      You forgot {}
      @CristianoNarcisiVidex said in Customizing a Gradient using QML:

      gradient: BlueGradient

      gradient: BlueGradient{}

      1 Reply Last reply
      3
      • C Offline
        C Offline
        CristianoNarcisiVidex
        wrote on last edited by
        #3

        ... ... ... Thanks a lot and sorry for posting this stupdi questions!!!

        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