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. Change the color overlay for hover on a QML Button
Forum Updated to NodeBB v4.3 + New Features

Change the color overlay for hover on a QML Button

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

    I just made the change from Qt 5.12.3 to 6.1.2. Having done this I went ahead and compiled a very simple QML App:

    import QtQuick 2.12
    import QtQuick.Window 2.12
    import QtQuick.Controls 2.0
    
    ApplicationWindow {
    
        id: mainWindow
    
        visible: true
        //visibility: Window.Maximized
        width: 1000
        height: 800
        title: qsTr("Hello World")
    
        Button {
            id: myTestButton
            width: 100
            height: 50
            text: "Click Me!"
            anchors.centerIn: parent
            //hoverEnabled: false
            onClicked: {
                console.log("Button Was clicked")
            }
        }
    }
    

    When I hover over the button now, it slowñy gets covered by a slight blue tranparent overlay while the mouse is over the button. I can disable this by setting hoverEnabled to false, but I much rather change it to something that I can use. How can change the color of this hover overlay?

    raven-worxR 1 Reply Last reply
    0
    • aarelovichA aarelovich

      I just made the change from Qt 5.12.3 to 6.1.2. Having done this I went ahead and compiled a very simple QML App:

      import QtQuick 2.12
      import QtQuick.Window 2.12
      import QtQuick.Controls 2.0
      
      ApplicationWindow {
      
          id: mainWindow
      
          visible: true
          //visibility: Window.Maximized
          width: 1000
          height: 800
          title: qsTr("Hello World")
      
          Button {
              id: myTestButton
              width: 100
              height: 50
              text: "Click Me!"
              anchors.centerIn: parent
              //hoverEnabled: false
              onClicked: {
                  console.log("Button Was clicked")
              }
          }
      }
      

      When I hover over the button now, it slowñy gets covered by a slight blue tranparent overlay while the mouse is over the button. I can disable this by setting hoverEnabled to false, but I much rather change it to something that I can use. How can change the color of this hover overlay?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @aarelovich
      see this: https://doc.qt.io/qt-5/qtquickcontrols2-customize.html#customizing-button
      and change the color of the background Rectangle when control.hovered is true

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved