qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.52k stars 2.99k forks source link

setting #RRGGBBAA color via data-defined override #40792

Closed kgjenkins closed 3 years ago

kgjenkins commented 3 years ago

Describe the bug When using an expression to set a feature's color using a data-defined override, it appears to be interpretting the order of color components incorrectly when using an 8-digit hex code. The expression help mentions a "#RRGGBBAA" format:

image

But it appears to be incorrectly interpreting 8-digit hex codes as "#AARRGGBB", while 6-digit hex codes are handled correctly, as shown here:

image

How to Reproduce

  1. Download test_hexcolor.zip
  2. Unzip and load the gpkg in QGIS
  3. Open the layer styling panel
  4. Set the point size to 10mm so the colors are easy to see
  5. Click "Simple Marker"
  6. For the fill color, click the data-defined override button > Edit...
  7. Set the expression to "color"

The second row of points should be a 50% opacity version of the first row. (The third row shows what the second row should look like.)

QGIS and OS versions

QGIS version 3.16.1-Hannover QGIS code revision b381a90dca Compiled against Qt 5.11.2 Running against Qt 5.11.2 Compiled against GDAL/OGR 3.1.4 Running against GDAL/OGR 3.1.4 Compiled against GEOS 3.8.1-CAPI-1.13.3 Running against GEOS 3.8.1-CAPI-1.13.3 Compiled against SQLite 3.29.0 Running against SQLite 3.29.0 PostgreSQL Client Version 11.5 SpatiaLite Version 4.3.0 QWT Version 6.1.3 QScintilla2 Version 2.10.8 Compiled against PROJ 6.3.2 Running against PROJ Rel. 6.3.2, May 1st, 2020 OS Version Windows 10 (10.0) Active python plugins crayfish; mmqgis; processing_r; processing_saga_nextgen; qgis_preview_mode_plugin; QNEAT3; QuickOSM; quick_map_services; Serval; SRTM-Downloader; valuetool; zoom_level; db_manager; processing

Additional context

I assume the expression help saying "#RRGGBBAA" is correct, since that is how color hexcodes are formatted in CSS.

roya0045 commented 3 years ago

related to #35308

gioman commented 3 years ago

So it is a "won't fix" here too I guess.

roya0045 commented 3 years ago

@gioman here the bug report state that the widget help/doc is wrong, the related ticket just provides context.

kgjenkins commented 3 years ago

Thanks, I hadn't seen that other issue #35308. I guess it makes sense not to break existing projects.

Can we at least update the help text, though? I'm not entirely sure, but I think this is where it is set: https://github.com/qgis/QGIS/blob/f32725658f205af4ac9718d3a3b74f13eaa98d3e/src/core/qgsproperty.cpp#L91

(It looks like the help for the color picker is specified elsewhere, and that works as advertised.)

roya0045 commented 3 years ago

@kgjenkins You can make a PR with the text correction. I don't think it should be problematic.

kgjenkins commented 3 years ago

Looks like @nyalldawson beat me to it -- thanks!