I try to customize the QgsFieldExpressionWidget. But if I open the Expression Dialog, the "Fields and Values" are empty. What I am missing?
lay= iface.activeLayer()
wid = QgsFieldExpressionWidget()
wid.setLayer=lay
scope= QgsExpressionContextUtils.layerScope(lay)# QgsExpressionContextScope()
scope.setFields (lay.fields())
wid.appendScope(scope)
wid.registerExpressionContextGenerator (lay)#QgsProject().instance())
wid.expressionDialogTitle="Test"
wid.setExpression('Foto IS NULL')
wid.show()
print (wid.currentText())