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. Style into button
Forum Updated to NodeBB v4.3 + New Features

Style into button

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 217 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.
  • elicatE Offline
    elicatE Offline
    elicat
    wrote on last edited by
    #1

    Hello I use version QT 5.14.2 and .. why I cannot use style into component button ??
    this error i see : Cannot assign to non-existent property "style"
    thanks for your answer.

    import QtQuick 2.0
    import QtQuick.Controls 2.14
    import QtQuick.Controls.Styles 1.4 
    import QtGraphicalEffects 1.0
    Button {
        id: buttonSimple 
        property var colSfondoBtnAlias 
        property var colSfondoGradientBtnAlias 
        property var objNameTabSplitAlias
        text: "Button"
        y: 0
        x: 0
        icon.name: "example"
        icon.source: "images/white/button_delete.png"
        icon.color: "#000000"
        style: ButtonStyle {
            background: Rectangle {
                id: rectanglebuttonCloseMenuFilter
                anchors.fill: parent
                border.width: control.activeFocus ? 2 : 1
                radius: 4
                gradient: Gradient {
                    GradientStop { position: 0 ; color: buttonSimple.pressed ? buttonSimple.colSfondoBtn :  buttonSimple.colSfondoGradientBtn }
                    GradientStop { position: 1 ; color: buttonSimple.pressed ? "#000000" : buttonSimple.colSfondoBtn }
                }    
            }
        }
    }
    
    

    Saluti, Gianfranco Elicat

    1 Reply Last reply
    0
    • MarkkyboyM Offline
      MarkkyboyM Offline
      Markkyboy
      wrote on last edited by Markkyboy
      #2

      See here; https://forum.qt.io/topic/79071/how-to-set-style-of-button-in-qml

      Try this;

      import QtQuick 2.12
      import QtQuick.Window 2.12
      import QtQuick.Controls 2.12
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          Button {
              id: control
              text: "Button"
              anchors.centerIn: parent
              background: Rectangle {
                  implicitWidth: 200
                  implicitHeight: 50
                  border.width: control.activeFocus ? 2 : 1
                  border.color: "#888"
                  radius: 4
                  gradient: Gradient {
                      GradientStop { position: 0 ; color: control.pressed ? "#ccc" : "#eee" }
                      GradientStop { position: 1 ; color: control.pressed ? "#aaa" : "#ccc" }
                  }
              }
          }
      }
      

      Don't just sit there standing around, pick up a shovel and sweep up!

      I live by the sea, not in it.

      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