I am writing a new plugin for QGIS 2.18. I can't find what are the libraries to import in my main code to access widgets such as QgsSpinBox or QgsFileWidget.
To properly use QT QGis custom widgets: Use imports such as: from PyQt4.QtGui import QDialog from qgis.gui import QgsFileWidget
You must also edit the xx_dialog_base.ui file, to ensure that the widgets are imported from the python module and not from the C libraries (it seems there is a bug in the generation of this .ui file, see Plugins crashing with "No module named qgsprojectionselectionwidget" in Windows?)
<customwidget> <class>QgsProjectionSelectionWidget</class> <extends>QWidget</extends> <header>qgsprojectionselectionwidget.h</header> </customwidget>
must be edited as:
<customwidget> <class>QgsProjectionSelectionWidget</class> <extends>QWidget</extends> <header>qgis.gui</header> </customwidget>
It seems this edit as to be repeated every time the .ui file is saved by QT designer.