/*设置label*/
QgsPalLayerSettings labelsettings;//label
labelsettings.fieldName="hello";
labelsettings.drawLabels=true;
// QgsTextFormat format;//label字体设置
// format.setColor(QColor(255,0,100));
// format.setFont(QFont("times"));
// labelsettings.setFormat(format);
// labelsettings.placement=QgsPalLayerSettings::OverPoint;
QgsVectorLayerSimpleLabeling *simpleL=new QgsVectorLayerSimpleLabeling(labelsettings);
pointVecLayer->setLabeling(simpleL);
pointVecLayer->setLabelsEnabled(true);
pointVecLayer->triggerRepaint(true);
bool isLabelShow=pointVecLayer->labelsEnabled();
qDebug()<<"is show"<<isLabelShow;//true
我用的是QGIS3.x的api,和2.x的有所不同,会的大佬劳驾您帮我指导下,thanks