For a simple example, have a look at Salvatore's answer to a GIS.SE question:
https://gis.stackexchange.com/a/273464/36921
Tom
-
Buy Pie Spy: Adventures in British pastry 2010-11 on Amazon
--
Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-Developer-f4099106.html
You are right, but how to use "setEditorWidgetSetup" method?
From doc reference:
QgsVectorLayer::setEditorWidgetSetup (int index, const QgsEditorWidgetSetup &
setup)
The first argument is the field index, ok, it's easy.
But second is a QgsEditorWidgetSetup, I don't know how to create one.