Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-105252

[QML] Compiler does not accept boolean type cast

    XMLWordPrintable

Details

    • b184d02648 (qt/qtdeclarative/dev) b184d02648 (qt/tqtc-qtdeclarative/dev) d1a6e6884b (qt/qtdeclarative/6.4) d1a6e6884b (qt/tqtc-qtdeclarative/6.4)

    Description

      Using "!!" to convert to boolean like this

      import QtQuick
      
      Window {
          width: 640
          height: 480
          visible: true
          title: 'Accept my string'
      
          Item {
              id: foo
              enabled: !!foo.myString
              property string myString: ''
          }
      }
      

      turns into

      Error: main.qml:11:24: Could not compile binding for enabled: cannot convert from QString of (component in /home/brms8522/projects/qt/build-colortyperesolve-Desktop_Qt_6_4_0_GCC_64bit-Debug/main.qml)::myString with type QString to boolean
              enabled: !!foo.myString
                             ^^^^^^^

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ulherman Ulf Hermann
            cajus Cajus Pollmeier
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes