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. Blue highlight on button press.
Forum Updated to NodeBB v4.3 + New Features

Blue highlight on button press.

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

    Qt Version: 6.6.0

    (Sorry for anything weird, I'm a newbie in Qt)

    As said in the title. When I click on a button, it's getting this blue highlight.

    Here's how its looking like:
    8278d13f-9094-4621-9039-e525ea476fba-image.png
    6ec207df-7bfd-4b07-ae65-644380509a80-image.png
    5fdc4357-76ab-4e82-a00f-65c1466024bb-image.png

    My QML file for menu buttons:

    import QtQuick 2.15
    import QtQuick.Controls 2.15
    import Qt5Compat.GraphicalEffects
    
    Button {
        id: menuButton
        implicitWidth: 480
        implicitHeight: 480
        flat: true
        smooth: false
    
        property url iconPath: "../../img/homeIcon.svg"
        property color iconColor: "#818181"
        property color sideIndicatorColor: "#882ac0"
        property color colorDefault: "#ff0000"
        property color colorHover: "#00ff00"
        property color colorClicked: "#ff00ff"
        property bool leftIndicator: true
        property bool rightIndicator: false
        property bool isActive: true
    
        QtObject {
            id: internal
    
            property color dynamicColor: if (menuButton.down) {
                menuButton.down ? colorClicked : colorDefault
            } else {
                menuButton.hovered ? colorHover : colorDefault
            }
        }
    
        background: Rectangle {
            id: bg
            visible: true
            anchors.fill: parent
            activeFocusOnTab: false
            focus: false
            layer.enabled: false
            color: internal.dynamicColor
    
            Rectangle {
                id: imgContainer
                x: 0
                y: 0
                width: 68
                height: 68
                opacity: 1
                visible: true
                color: "#00ffffff"
                border.color: "#00000000"
    
                Image {
                    id: img
                    source: iconPath
                    mipmap: true
                    smooth: true
                    antialiasing: true
                    anchors.verticalCenterOffset: 0
                    anchors.horizontalCenterOffset: 0
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.horizontalCenter: parent.horizontalCenter
                    anchors {
                        right: rightSideIndicator
                        rightMargin: 0
                    }
    
                    height: parent.height * 1
                    fillMode: Image.PreserveAspectFit
                }
    
                ColorOverlay {
                        anchors.fill: img
                        source: img
                        color: iconColor
                        antialiasing: true
                }
            }
    
            Rectangle {
                id: rightSideIndicator
                color: sideIndicatorColor
                anchors.rightMargin: -2
                anchors {
                    top: parent.top
                    bottom: parent.bottom
                    right: parent.right
                    left: imgContainer.right
                    topMargin: 0
                    bottomMargin: 0
                    leftMargin: 0
                }
                visible: isActive & rightIndicator ? true : false
    
            }
    
            Rectangle {
                id: leftSideIndicator
                color: sideIndicatorColor
                anchors.rightMargin: -2
                anchors {
                    top: parent.top
                    bottom: parent.bottom
                    right: imgContainer.left
                    left: parent.left
                    topMargin: 0
                    bottomMargin: 0
                    leftMargin: 0
                }
                visible: isActive & leftIndicator ? true : false
    
            }
        }
    }
    
    MarkkyboyM 1 Reply Last reply
    0
    • katekyyK katekyy

      Qt Version: 6.6.0

      (Sorry for anything weird, I'm a newbie in Qt)

      As said in the title. When I click on a button, it's getting this blue highlight.

      Here's how its looking like:
      8278d13f-9094-4621-9039-e525ea476fba-image.png
      6ec207df-7bfd-4b07-ae65-644380509a80-image.png
      5fdc4357-76ab-4e82-a00f-65c1466024bb-image.png

      My QML file for menu buttons:

      import QtQuick 2.15
      import QtQuick.Controls 2.15
      import Qt5Compat.GraphicalEffects
      
      Button {
          id: menuButton
          implicitWidth: 480
          implicitHeight: 480
          flat: true
          smooth: false
      
          property url iconPath: "../../img/homeIcon.svg"
          property color iconColor: "#818181"
          property color sideIndicatorColor: "#882ac0"
          property color colorDefault: "#ff0000"
          property color colorHover: "#00ff00"
          property color colorClicked: "#ff00ff"
          property bool leftIndicator: true
          property bool rightIndicator: false
          property bool isActive: true
      
          QtObject {
              id: internal
      
              property color dynamicColor: if (menuButton.down) {
                  menuButton.down ? colorClicked : colorDefault
              } else {
                  menuButton.hovered ? colorHover : colorDefault
              }
          }
      
          background: Rectangle {
              id: bg
              visible: true
              anchors.fill: parent
              activeFocusOnTab: false
              focus: false
              layer.enabled: false
              color: internal.dynamicColor
      
              Rectangle {
                  id: imgContainer
                  x: 0
                  y: 0
                  width: 68
                  height: 68
                  opacity: 1
                  visible: true
                  color: "#00ffffff"
                  border.color: "#00000000"
      
                  Image {
                      id: img
                      source: iconPath
                      mipmap: true
                      smooth: true
                      antialiasing: true
                      anchors.verticalCenterOffset: 0
                      anchors.horizontalCenterOffset: 0
                      anchors.verticalCenter: parent.verticalCenter
                      anchors.horizontalCenter: parent.horizontalCenter
                      anchors {
                          right: rightSideIndicator
                          rightMargin: 0
                      }
      
                      height: parent.height * 1
                      fillMode: Image.PreserveAspectFit
                  }
      
                  ColorOverlay {
                          anchors.fill: img
                          source: img
                          color: iconColor
                          antialiasing: true
                  }
              }
      
              Rectangle {
                  id: rightSideIndicator
                  color: sideIndicatorColor
                  anchors.rightMargin: -2
                  anchors {
                      top: parent.top
                      bottom: parent.bottom
                      right: parent.right
                      left: imgContainer.right
                      topMargin: 0
                      bottomMargin: 0
                      leftMargin: 0
                  }
                  visible: isActive & rightIndicator ? true : false
      
              }
      
              Rectangle {
                  id: leftSideIndicator
                  color: sideIndicatorColor
                  anchors.rightMargin: -2
                  anchors {
                      top: parent.top
                      bottom: parent.bottom
                      right: imgContainer.left
                      left: parent.left
                      topMargin: 0
                      bottomMargin: 0
                      leftMargin: 0
                  }
                  visible: isActive & leftIndicator ? true : false
      
              }
          }
      }
      
      MarkkyboyM Offline
      MarkkyboyM Offline
      Markkyboy
      wrote on last edited by
      #2

      @katekyy - what actually is your question?, do you not want the blue highlight?, please clarify exactly what it is you are asking as it is not clear to me and probably other users.

      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