This question already has an answer here:
I am creating a plugin for QGIS where I, amongst other things, have to create a shapefile layer.
My problem is using the QgsVectorLayer. I tried following the answer in Problem creating point shapefiles programmatically using python in QGIS 2.2
Which works great if I call it in the Python console in QGIS, but if I try to do it from my plugin, I get the error: "NameError: global name 'QgsVectorLayer' is not defined".
I am using QGIS 2.16.3
I already have 'from PyQt4.QtCore import *' shouldn't that be enough?
For some reason I thought qgis.core and PyQt4.QtCore were the same thing. It was the missing imports.