<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">I've just tested this on QGIS Master
      and get exactly the same result you describe. I also tried
      rule-based rendering but the colours don't get carried through to
      the legend either.<br>
      <br>
      I wonder if this is a bug?<br>
      <br>
      Frank.<br>
      <br>
      On 17/07/2017 14:23, Immo Blecher wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:671777e9-0f3f-10aa-e497-9f26bf62f4da@gmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <p>Sorry Frank, I realised later that I did not send that info. Here it is:
<style type="text/css">
p, li { white-space: pre-wrap; }
</style>
</p>
      <table style=" margin-top:0px; margin-bottom:0px; margin-left:0px;
        margin-right:0px;" border="0" cellspacing="2" cellpadding="0"
        align="center" width="100%">
        <tbody>
          <tr>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">QGIS version</p>
            </td>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">2.18.10</p>
            </td>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">QGIS code revision</p>
            </td>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://github.com/qgis/QGIS/commit/59e0f78" moz-do-not-send="true"><span style=" text-decoration: underline; color:#0000ff;">59e0f78</span></a></p>
            </td>
          </tr>
          <tr>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Compiled against Qt</p>
            </td>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">4.8.7</p>
            </td>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Running against Qt</p>
            </td>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">4.8.7</p>
            </td>
          </tr>
          <tr>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Compiled against GDAL/OGR</p>
            </td>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">1.11.3</p>
            </td>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Running against GDAL/OGR</p>
            </td>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">1.11.3</p>
            </td>
          </tr>
          <tr>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Compiled against GEOS</p>
            </td>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">3.5.0-CAPI-1.9.0</p>
            </td>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Running against GEOS</p>
            </td>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">3.5.0-CAPI-1.9.0 r4084</p>
            </td>
          </tr>
          <tr>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">PostgreSQL Client Version</p>
            </td>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">9.5.2</p>
            </td>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">SpatiaLite Version</p>
            </td>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">4.3.0a</p>
            </td>
          </tr>
          <tr>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">QWT Version</p>
            </td>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">5.2.3</p>
            </td>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">PROJ.4 Version</p>
            </td>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">492</p>
            </td>
          </tr>
          <tr>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">QScintilla2 Version</p>
            </td>
            <td>
              <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">2.9.1</p>
            </td>
            <td><br>
            </td>
            <td><br>
            </td>
          </tr>
        </tbody>
      </table>
      <br>
      And I run it under Ubuntu 16.04 LTS<br>
      <br>
      Thanks<br>
      Immo<br>
      <br>
      <div class="moz-cite-prefix">On 17/07/2017 14:19, Frank Sokolic
        via qgis-za-user wrote:<br>
      </div>
      <blockquote type="cite"
        cite="mid:446917de-9cc4-b329-7b65-1cd56498c5ce@worldonline.co.za">
        <meta http-equiv="Content-Type" content="text/html;
          charset=utf-8">
        <div class="moz-cite-prefix">Hi Immo,<br>
          <br>
          Which version of QGIS are you using?<br>
          <br>
          Frank.<br>
          <br>
          On 17/07/2017 09:48, Immo Blecher via qgis-za-user wrote:<br>
        </div>
        <blockquote type="cite"
          cite="mid:6b8b6325-8094-2b01-ec0d-370f9bcca053@gmail.com">
          <meta http-equiv="content-type" content="text/html;
            charset=utf-8">
          <p>Good Morning Everyone,</p>
          <p>I have a geology layer with a few columns, including the
        chronostratigraphic symbol, the rock type description and,
        importantly, a colour column (String type). The values stored in
        the colour column are the HTML hex values for the colour
        according to the 1 : 1 000 000 simplified geological map of
        South Africa.</p>
          <p>When I open the layer and select the colour column for
        colouring the lithological units it works beautifully, but I do
        not get a legend for the composer. But if I set the
        Properties|Style to Categorized and then again select the colour
        from the Colour column in the table I also get the same nicely
        coloured map according to the colour column, an a Legend. But
        the Legend is wrong...it chooses random colours! What am I doing
        wrong? Is there a way to get a correct legend, also only showing
        the units which are actually on the map in the composer. I can
        set the colours manually to match the value in the colour field
        but that sort of defeats the purpose.</p>
          <p>Thanks for your help so long,</p>
          <p>Immo

      </p>
          <div class="moz-signature">-- <br>
            <meta http-equiv="content-type" content="text/html;
              charset=utf-8">
            <title></title>
            <div class="moz-signature">
              <div class="moz-signature">
                <p style="background: transparent; border: none; padding:
              0in"><strong><font color="#000000">Immo F. Blecher</font></strong><strong><font color="#808080">

                  Street: </font></strong><em><font color="#808080"> 52
                  Lynedoch Eco Village, Lynedoch, 7603, South Africa

                </font></em><em><font color="#808080"><span style="font-style: normal"><b>Postal:</b></span></font></em><em><font color="#808080"> 52 Lynedoch Eco Village, Lynedoch,
                  7603, South Africa

                </font></em><em><font color="#808080"><span style="font-style: normal"><b>Cell:</b></span></font></em><em><font color="#000000"> </font></em><font color="#808080">+27
                83 272 6791 </font><font color="#ff6600">|</font><font color="#666666"> </font><font color="#666666"><b>Fax: </b></font><font color="#808080">+27 86 7363302 </font><font color="#808080"><b>Email:</b></font><font color="#808080"> </font><a href="mailto:immo@blecher.co.za" moz-do-not-send="true"><font color="#0000ff"><u>immo@blecher.co.za</u></font></a> <font color="#ff6600">| </font><a href="mailto:immob19@gmail.com" moz-do-not-send="true"><font color="#0000ff"><u>immob19@gmail.com</u></font></a><font color="#0000ff"><span style="text-decoration: none"> </span></font><font color="#ff6600"><span style="text-decoration: none">| </span></font><font color="#0000ff"><u><a href="mailto:immob@mymtnmail.co.za" moz-do-not-send="true">immob@mymtnmail.co.za</a>

                </u></font><font color="#666666"><span style="text-decoration: none"><b>Internet:</b></span></font><font color="#666666"><span style="text-decoration: none"> </span></font><a href="http://www.blecher.co.za/" moz-do-not-send="true"><font color="#0000ff"><span style="text-decoration: none"><u>http://www.blecher.co.za/</u></span></font></a></p>
                <img
src="http://p1.wisestamp.com/pixel.png?p=mozilla&v=2.9.5&t=1320849250746&u=82e4b3250c4ca423"
                  name="graphics6" moz-do-not-send="true" border="0"
                  align="BOTTOM" width="2" height="2">
                <div id="WISESTAMP_SIG_9425" dir="LTR"><br>
                </div>
              </div>
            </div>
          </div>
          <br>
          <fieldset class="mimeAttachmentHeader"></fieldset>
          <br>
          <pre wrap="">_______________________________________________
qgis-za-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:qgis-za-user@lists.osgeo.org" moz-do-not-send="true">qgis-za-user@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-za-user" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-za-user</a>
</pre>
        </blockquote>
        <p>

    </p>
        <br>
        <fieldset class="mimeAttachmentHeader"></fieldset>
        <br>
        <pre wrap="">_______________________________________________
qgis-za-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:qgis-za-user@lists.osgeo.org" moz-do-not-send="true">qgis-za-user@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-za-user" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-za-user</a>
</pre>
      </blockquote>
      <br>
      <div class="moz-signature">-- <br>
        <meta http-equiv="content-type" content="text/html;
          charset=utf-8">
        <title></title>
        <div class="moz-signature">
          <div class="moz-signature">
            <p style="background: transparent; border: none; padding: 0in"><strong><font color="#000000">Immo F. Blecher</font></strong><strong><font color="#808080">

              Street: </font></strong><em><font color="#808080">
              52 Lynedoch Eco Village, Lynedoch, 7603, South Africa

            </font></em><em><font color="#808080"><span style="font-style: normal"><b>Postal:</b></span></font></em><em><font color="#808080"> 52 Lynedoch Eco Village, Lynedoch, 7603, South
              Africa

            </font></em><em><font color="#808080"><span style="font-style: normal"><b>Cell:</b></span></font></em><em><font color="#000000"> </font></em><font color="#808080">+27 83
            272 6791 </font><font color="#ff6600">|</font><font color="#666666"> </font><font color="#666666"><b>Fax: </b></font><font color="#808080">+27 86 7363302 </font><font color="#808080"><b>Email:</b></font><font color="#808080"> </font><a href="mailto:immo@blecher.co.za" moz-do-not-send="true"><font color="#0000ff"><u>immo@blecher.co.za</u></font></a> <font color="#ff6600">| </font><a href="mailto:immob19@gmail.com" moz-do-not-send="true"><font color="#0000ff"><u>immob19@gmail.com</u></font></a><font color="#0000ff"><span style="text-decoration: none"> </span></font><font color="#ff6600"><span style="text-decoration: none">| </span></font><font color="#0000ff"><u><a href="mailto:immob@mymtnmail.co.za" moz-do-not-send="true">immob@mymtnmail.co.za</a>

            </u></font><font color="#666666"><span style="text-decoration: none"><b>Internet:</b></span></font><font color="#666666"><span style="text-decoration: none"> </span></font><a href="http://www.blecher.co.za/" moz-do-not-send="true"><font color="#0000ff"><span style="text-decoration: none"><u>http://www.blecher.co.za/</u></span></font></a></p>
            <font face="Verdana, Arial, Helvetica, sans-serif"><font
                size="1"><font color="#808080">Contact me: </font> <img
                  src="http://images.wisestamp.com/gtalk.png"
                  name="graphics2" moz-do-not-send="true" border="0"
                  align="BOTTOM" width="16" height="16"> <a
                  class="moz-txt-link-abbreviated"
                  href="mailto:immob19@gmail.com" moz-do-not-send="true">immob19@gmail.com</a>
                <img src="http://images.wisestamp.com/skype.png"
                  name="graphics3" moz-do-not-send="true" border="0"
                  align="BOTTOM" width="16" height="16"> immoblecher</font></font>
            <div id="WISESTAMP_SIG_9425" dir="LTR">
              <p style="margin-bottom: 0in; border-top: 1px solid #e5e5e5;
            border-bottom: none; border-left: none; border-right: none;
            padding-top: 0.02in; padding-bottom: 0in; padding-left: 0in;
            padding-right: 0in"> <a href="http://www.linkedin.com/pub/immo-blecher/30/414/b8" moz-do-not-send="true"><img src="http://images.wisestamp.com/apps/buttons/linkedinbutton_option_1.png" name="graphics4" moz-do-not-send="true" border="0" align="BOTTOM" width="160" height="33"></a></p>
              <table cellspacing="2" cellpadding="2" width="100%">
                <tbody>
                  <tr valign="TOP">
                    <td style="border: none; padding: 0in" width="1%">
                      <p style="border-top: none; border-bottom: none;
                    border-left: none; border-right: 1px solid #e5e5e5;
                    padding-top: 0in; padding-bottom: 0in; padding-left:
                    0in; padding-right: 0.05in"> <img src="http://images.wisestamp.com/widgets/green_32.png" name="graphics5" moz-do-not-send="true" border="0" align="BOTTOM" width="32" height="32"></p>
                    </td>
                    <td style="border: none; padding: 0in">
                      <p style="border: none; padding: 0in">Please consider
                    your environmental responsibility. Before printing
                    this e-mail message, ask yourself whether you really
                    need a hard copy.</p>
                    </td>
                  </tr>
                </tbody>
              </table>
              <p style="margin-bottom: 0in; border-top: 1px solid #808080;
            border-bottom: none; border-left: none; border-right: none;
            padding-top: 0.02in; padding-bottom: 0in; padding-left: 0in;
            padding-right: 0in"> <font color="#808080"><font face="Verdana, Arial, Helvetica, sans-serif"><font size="1">IMPORTANT: The contents of this email and any
                  attachments are confidential. They are intended for
                  the named recipient(s) only. If you have received this
                  email by mistake, please notify the sender immediately
                  and do not disclose the contents to anyone or make
                  copies thereof.</font></font></font></p>
              <p style="margin-bottom: 0in"><img src="http://p1.wisestamp.com/pixel.png?p=mozilla&v=2.9.5&t=1320849250746&u=82e4b3250c4ca423" name="graphics6" moz-do-not-send="true" border="0" align="BOTTOM" width="2" height="2"></p>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <p>
</p>
  </body>
</html>