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

QColor::fromHsvF allows invalid hue value

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P4: Low
    • None
    • 5.13.0 Beta3
    • GUI: Painting
    • None
    • All

    Description

      It is - both by the documentation (e.g. QColor::fromHsvF and QML's hsva method) and the implementation - absolutely ok to create a QColor with a hue value of 1 (QColor::fromHsvF).

      When retrieving the (non-float) hue value via QColor::getHsv, the result is 360. But the valid range for hue values in hsv representation is 0 - 359 (inclusive), as documented in several locations of the QColor class, and enforced in the code (e.g. QColor::fromHsv), as this little snippets shows:

      QColor c = QColor::fromHsvF(1, 0, 0);
      int h = 0, s, v;
      c.getHsv(&h, &s, &v);
      qDebug() << h;  // 360
      

      Imho, it should be disallowed to set a hue value of 1.0 (because the actual range is between 0 (inclusive) to 1 (exclusive)) or at least a value of 1.0 should be sanitized to 0.

      Attachments

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

        Activity

          People

            vgt Eirik Aavitsland
            moerkb Markus Bader
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes