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

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

    XMLWordPrintable

Details

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

    Description

      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.

      Attachments

        Issue Links

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

          Activity

            People

              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

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes