I'm a newer of qgis

I write a C++ application.
I want to set a layer's label when it smaller than 1.00mm will be not visible.

My code is as follows:
void LayerMgr::showLabels(QgsVectorLayer *layer, bool opt)
{
    int index = 0;
    QString attrName = "name";
    QgsPalLayerSettings  labelSetting;
    QgsLabel *layerLabel = layer->label();
    QgsFields field = layer->dataProvider()->fields();

    if (false == opt)
    {
        layer->enableLabels(false);
        return;
    }

    for (index = 0; index < field.size(); index++)
    {
        if (QString(field[index].name()) == attrName)
        {
            break;
        }
    }

    labelSetting.enabled = true;
    labelSetting.fieldName = QString(field[index].name());
    labelSetting.textColor = Qt::black;
    labelSetting.minFeatureSize = 10.0;
    labelSetting.writeToLayer(layer);
    mpMapCanvas->refresh();
}

But it was not usful.Who can help me.
Thank you very much.
_______________________________________________
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to