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. QML button's palette with enabled property
Forum Updated to NodeBB v4.3 + New Features

QML button's palette with enabled property

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 2.0k 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.
  • U Offline
    U Offline
    Usserr
    wrote on 21 Mar 2020, 15:01 last edited by
    #1

    Hello

    I am using the raw of buttons to perform some actions and at the same time to represent the current state of the project. So I use palette.button to set the current color. When the button has been clicked by the user it should go to disabled state for the action running time. So I do enabled = false. All works as expected except that the button visually stays in the disabled state (text is faded) even after I re-enable it (enabled = true) though it is, in fact, active now (I can click on it and the action will propagate). It seems like non-default palettes aren't compatible with enabled property. Is it a known behavior or I'm missing something?

    I am using PySide2. QML imports are:

    import QtQuick 2.12
    import QtQuick.Controls 2.12
    import QtQuick.Layouts 1.12
    import QtGraphicalEffects 1.12
    import QtQuick.Dialogs 1.3 as QtDialogs
    
    import Qt.labs.platform 1.1 as QtLabs
    
    import ProjectListItem 1.0
    import Settings 1.0
    

    screenshot1

    1 Reply Last reply
    0
    • U Offline
      U Offline
      Usserr
      wrote on 28 Mar 2020, 12:09 last edited by
      #3

      OK, I guess I should just set buttonText property explicitly when manipulating button's palette so the text always will be in the desired state. Not very elegant but anyway... Probably can use State component to group both changes in background and text under one thing.

      1 Reply Last reply
      0
      • 6 Offline
        6 Offline
        6thC
        wrote on 23 Mar 2020, 06:55 last edited by
        #2

        I don't know. But: https://doc.qt.io/qt-5/qpalette.html#ColorRole-enum gives... something.
        But also, if you dig into source you could probably know what you are looking to seek (I don't know exactly your situation but you can find out).

        I.e. for me ( QML ) I'd start digging and find out how things are, places things like:
        "\Qt<version><kit>\qml\QtQuick\Controls.2\Button.qml" for example:

        background: Rectangle {
            implicitWidth: 100
            implicitHeight: 40
            visible: !control.flat || control.down || control.checked || control.highlighted
            color: Color.blend(control.checked || control.highlighted ? control.palette.dark : control.palette.button,
                                                                        control.palette.mid, control.down ? 0.5 : 0.0)
            border.color: control.palette.highlight
            border.width: control.visualFocus ? 2 : 0
        }
        

        and if I'd used Material theme see@ "\Qt<version><kit>\qml\QtQuick\Controls.2\Material\Button.qml" for example:

        color: !control.enabled ? control.Material.buttonDisabledColor :
                    control.highlighted ? control.Material.highlightedButtonColor : control.Material.buttonColor
        

        Anyhow, point is, you might find just a theme might do it - possibly not. In which case, you can always overwrite the background delegate for fine tuning yourself. Or any other section that doesn't quite do it for you.

        1 Reply Last reply
        0
        • U Offline
          U Offline
          Usserr
          wrote on 28 Mar 2020, 12:09 last edited by
          #3

          OK, I guess I should just set buttonText property explicitly when manipulating button's palette so the text always will be in the desired state. Not very elegant but anyway... Probably can use State component to group both changes in background and text under one thing.

          1 Reply Last reply
          0

          1/3

          21 Mar 2020, 15:01

          • Login

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