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

SH_Table_GridLineColor does not support alpha

    XMLWordPrintable

    Details

    • Type: Suggestion
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Done
    • Affects Version/s: 5.6.1
    • Fix Version/s: None
    • Labels:
      None
    • Commits:
      41702d8455a9e88ac70108e500a10e7bd4df2771 (qt/qtbase/5.15)

      Description

      Hello,

      We have a custom style that wants to provide a custom SH_Table_GridLineColor, but we found that the alpha channel of the returned color is ignored. We'd like a color that includes alpha to make it blend in a certain way with the underlying content in the item view.

      To be fair, this seems implied by the documentation for the style hint, which describes it as: 

      The RGB value of the grid for a table.

      ... but it's not clear if the alpha channel is ignored by design.

      The problem appears to be that QTableView::paintEvent() explicitly converts the returned value into a color as follows:

      const int gridHint = style()->styleHint(QStyle::SH_Table_GridLineColor, ...);
      const QColor gridColor = static_cast<QRgb>(gridHint); 

      The implicit conversion from QRgb to QColor is documented to ignore the alpha channel (presumably for some historical reason).

      Could this code instead use QColor::fromRgba() to preserve the color's alpha if the style wants to make use of it? If not, is there a specific reason why this behavior is undesirable, and could this be documented more clearly so that clients know what to expect?

      Thanks in advance, and please let me know if we can provide any more information.

        Attachments

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

          Activity

            People

            Assignee:
            chehrlic Christian Ehrlicher
            Reporter:
            jmk Jason Kim
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes