Details
-
Suggestion
-
Resolution: Done
-
P3: Somewhat important
-
None
-
5.6.1
-
None
-
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.