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

Validation of enums being passed between C++ and QML

XMLWordPrintable

      A typical misuse case goes like:

      C++:

      engine.rootContext()->setContextProperty("align", Qt::AlignCenter);
      

      QML:

          Text {
              anchors.fill: parent
              text: "Hello World!"
              horizontalAlignment: align
          }
      

      Since "AlignCenter" is "AlignHCenter | AlignVCenter" and the result does not make any sense in QML, the rendering result looks weird. But yet, the code compiles and runs since enum is essentially just integer and nothing stops such misuse from happening.

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

            qtqmlteam Qt Qml Team User
            luqiaochen Luqiao Chen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes