<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    (QGis version 2.6)<br>
    I am trying to delete some legend rows with the python API. I works
    fine for the Subgroups but I can't remove the rows inside a Subgroup
    (the Symbols).<br>
    <br>
    This is the legend in the generated .png file, I want to remove the
    row "Less than 50.0".<br>
    <img src="cid:part1.06020808.00040906@openocean.fr" alt=""><br>
    <br>
    In my python script (I only have 1 column so the column index is
    always 0):<br>
    <i>legend = qgs.core.QgsComposerLegend(composer)</i><br>
    <i>subgroup = legend.modelV2().index(0, 0) # Grabs my first subgroup
      in the legend, "Bathymetry [m]"</i><i><br>
    </i><i>
      legend.modelV2().removeRow(0) # Removes the first subgroup,
      returns True (works)</i><br>
    <br>
    Now, I want to remove the first symbol of my second subgroup,
    "Population density [people/km²]" - the first symbol label is "Less
    than 50.0"<br>
    First, I grab the QModelIndex of the row I want to delete, to verify
    it's the good one.<br>
    This time, I didn't remove the "Bathymetry [m]" subgroup from the
    legend, so I access the "Population density" subgroup with the row
    index 1.<br>
    <i>subgroup = legend.modelV2().index(1, 0)</i><i><br>
    </i><i>
      print subgroup.data() # "Population density [people/km²]"</i><i><br>
    </i><i>
      symbol = subgroup.child(0, 0)</i><i><br>
    </i><i>
      print symbol.data() # "Less than 50.0" => this is the one I
      want to delete</i><br>
    <br>
    I tried several methods to remove it, none worked...<br>
    <i>legend.modelV2().removeRow(0, symbol.parent()) # Returns False
      (doesn't work</i><i>)<br>
    </i><i>
      legend.modelV2().removeRow(0, subgroup) # Returns False (doesn't
      work</i>)<br>
    Same with <i>removeRows(0, 1, symbol.parent())</i>...<br>
    I also tried to remove other rows from this subgroup, and it never
    worked.<br>
    <br>
    Am I doing something wrong ? Do you have a hint on how I should
    proceed to remove this ?<br>
    <br>
    Thank you,<br>
    <div class="moz-signature">-- <br>
      <font color="#C0C0C0" face="Droid Sans" size="2">Raphaël Dubois<br>
        Project Engineer<br>
        Open Ocean SAS<br>
        27 rue du Chemin Vert<br>
        75011 Paris<br>
        +33(0)9 7239 0165<br>
        <br>
        <a href="mailto:raphael.dubois@openocean.fr">raphael.dubois@openocean.fr</a><br>
        <a href="http://www.openocean.fr">http://www.openocean.fr<br>
        </a></font><a href="http://www.openocean.fr">
        <img src="cid:part4.05080500.01020507@openocean.fr"
          style="padding: 4px; margin: 0 7px 2px 0; display: inline;
          float: left;" height="50" width="200"></a>
      <br>
      <br>
      <br>
      <br>
    </div>
  </body>
</html>