qgis-sample-QgsFieldComboBox.py
from PyQt4.QtGui import QDialog, QFormLayout
from qgis.gui import (QgsFieldComboBox, QgsMapLayerComboBox,
QgsMapLayerProxyModel)
new_dialog = QDialog()
map_layer_combo_box = QgsMapLayerComboBox()
map_layer_combo_box.setCurrentIndex(-1)
map_layer_combo_box.setFilters(QgsMapLayerProxyModel.VectorLayer)
field_combo_box = QgsFieldComboBox()
layout = QFormLayout()
layout.addWidget(map_layer_combo_box)
layout.addWidget(field_combo_box)
map_layer_combo_box.layerChanged.connect(field_combo_box.setLayer)
def on_field_changed(fieldName):
print(fieldName)
print("Layer field changed")
field_combo_box.fieldChanged.connect(on_field_changed)
new_dialog.setLayout(layout)
new_dialog.show()