QgsVectorLayer* layer = new QgsVectorLayer("/path/to/layer.shp", "layer", "ogr"); QgsFields fields = layer->fields(); for (int i = 0; i < fields.count(); i++) { QgsField field = fields.at(i); qDebug() << field.name(); }This code creates a QgsVectorLayer object from a shapefile, gets the fields from the layer, and prints the name of each field to the console. The package library for QgsVectorLayer is qgis_core.