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

color in QML should be constructible from Qt::color enumerations

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • 6.7
    • 5.15.2
    • None

      Currently one can build a color in QML from

      • (a QColor in C++)
      • a string representing a SVG color name
      • a string in hash+hexadecimal (#RRGGBB)
      • a construction function like Qt.rgba()

      A direct conversion from the Qt::GlobalColor enumeration is missing, although the enumerators themselves are exposed to QML:

      Rectangle {
        color: Qt.red // ERROR: no int -> color conversion
      }
      

      The error shows that the problem is deeper than a mere "conversion" but has to do with the messed-up state of enumerations in QML (sometimes being integers, sometimes being enumerations).

      While at it, it would be niceā„¢ to have the color constants in QColorConstants exposed in QML as named objects, avoiding the risk of typos and the cost of parsing a string.

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

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            peppe Giuseppe D'Angelo
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes