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. Button property undefined
Forum Updated to NodeBB v4.3 + New Features

Button property undefined

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 312 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.
  • N Offline
    N Offline
    nixako2186
    wrote on 29 Jan 2024, 19:50 last edited by
    #1

    Hi,
    I couldn't find any information inside documentation regarding this behavior.
    property bool enabled is overridden inside button.
    Dummy1 is set to disabled and looks like it is disabled but all events and other visual styles are working on it.
    Dummy2 is working fine.
    Is this bug, undefined behavior or it is working as expected?
    Commenting out "property bool enabled" make Dummy1 work as expected (disabled)

    //main.qml
    import QtQuick 2.9
    import QtQuick.Controls 2.5
    import QtQuick.Controls.Material 2.12
    
    ApplicationWindow {
        visible: true
        width: 800; height: 600
        ButtonProblem {
            id: button1
            enabled: false
            text: "Dummy1"
        }
        ButtonProblem {
            id: button2
            y: 50
            enabled: true
            text: "Dummy2"
        }
    }
    
    //ButtonProblem.qml
    import QtQuick 2.9
    import QtQuick.Controls 2.5
    
    Button {
        property bool enabled
        onPressed: { console.log("onPressed") }
        onClicked: { console.log("onClicked") }
    }
    

    27bb8cee-6633-42fe-a3c5-caa1e71bc4ee-image.png
    As you can see it can be pressed:
    02958663-e371-4bef-afa3-b74a72e4d74c-image.png

    Additional info:
    QQuickStyle::setStyle("Material");
    Qt5.12.12

    J 1 Reply Last reply 29 Jan 2024, 20:09
    0
    • N nixako2186
      29 Jan 2024, 19:50

      Hi,
      I couldn't find any information inside documentation regarding this behavior.
      property bool enabled is overridden inside button.
      Dummy1 is set to disabled and looks like it is disabled but all events and other visual styles are working on it.
      Dummy2 is working fine.
      Is this bug, undefined behavior or it is working as expected?
      Commenting out "property bool enabled" make Dummy1 work as expected (disabled)

      //main.qml
      import QtQuick 2.9
      import QtQuick.Controls 2.5
      import QtQuick.Controls.Material 2.12
      
      ApplicationWindow {
          visible: true
          width: 800; height: 600
          ButtonProblem {
              id: button1
              enabled: false
              text: "Dummy1"
          }
          ButtonProblem {
              id: button2
              y: 50
              enabled: true
              text: "Dummy2"
          }
      }
      
      //ButtonProblem.qml
      import QtQuick 2.9
      import QtQuick.Controls 2.5
      
      Button {
          property bool enabled
          onPressed: { console.log("onPressed") }
          onClicked: { console.log("onClicked") }
      }
      

      27bb8cee-6633-42fe-a3c5-caa1e71bc4ee-image.png
      As you can see it can be pressed:
      02958663-e371-4bef-afa3-b74a72e4d74c-image.png

      Additional info:
      QQuickStyle::setStyle("Material");
      Qt5.12.12

      J Offline
      J Offline
      JoeCFD
      wrote on 29 Jan 2024, 20:09 last edited by
      #2

      @nixako2186 said in Button property undefined:

      enabled

      enabled is a property of Button. Why do you want to use it as a local property?

      N 1 Reply Last reply 29 Jan 2024, 20:23
      0
      • J JoeCFD
        29 Jan 2024, 20:09

        @nixako2186 said in Button property undefined:

        enabled

        enabled is a property of Button. Why do you want to use it as a local property?

        N Offline
        N Offline
        nixako2186
        wrote on 29 Jan 2024, 20:23 last edited by
        #3

        @JoeCFD
        I was experimenting with properties and their behavior and I just did it. I wanted to understand what is happening.
        As you can see it seems that this is somehow partially overridden. Visually it looks like disabled but functionally it works just fine.

        I know that this is property of Button but if it possible to override it then why not? Maybe it should be prevented by parser - final keyword on property inside Button.qml or at least described in documentation.

        J 1 Reply Last reply 29 Jan 2024, 21:24
        0
        • N nixako2186
          29 Jan 2024, 20:23

          @JoeCFD
          I was experimenting with properties and their behavior and I just did it. I wanted to understand what is happening.
          As you can see it seems that this is somehow partially overridden. Visually it looks like disabled but functionally it works just fine.

          I know that this is property of Button but if it possible to override it then why not? Maybe it should be prevented by parser - final keyword on property inside Button.qml or at least described in documentation.

          J Offline
          J Offline
          JoeCFD
          wrote on 29 Jan 2024, 21:24 last edited by JoeCFD
          #4

          @nixako2186 Since your code runs, this means you can override it. However, you may lose control over when your local enabled or the one defined in Button is used. Therefore, better never do it.

          1 Reply Last reply
          0

          1/4

          29 Jan 2024, 19:50

          • Login

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