<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'>
<p>Hi,</p>
<p>I found the "QgsValueRelationSearchWidgetWrapper" class, which seems to have a "setExpression" method - but I don't know how I can access and change the QgsValueRelationSearchWidgetWrapper of an existing ComboBox in the attribute form.</p>
<p>Andreas</p>
<p id="reply-intro">On 2023-02-13 11:31, Andreas Neumann via QGIS-Developer wrote:</p>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">
<div id="replybody1">
<div style="font-size: 10pt; font-family: Verdana,Geneva,sans-serif;">
<p>Hi,</p>
<p>I am looking for a code snippet in PyQGIS: how can I change the filter expression for a value relation widget?</p>
<p>Technically, the widget seems to be a QComboBox. I can get access to the combobox, e.g. to get the current value - but how can I access the QGIS related functionality, like changing programmatically settings of the value relation widget , such as the filter expression? I found the QgsValueRelationFieldFormatter object, but it doesn't allow me to change the filter expression. Any idea how I would change the filter expression using Python?</p>
<p>Thank you for any hints,</p>
<p>Andreas</p>
</div>
</div>
<br />
<div class="pre" style="margin: 0; padding: 0; font-family: monospace">_______________________________________________<br />QGIS-Developer mailing list<br /><a href="mailto:QGIS-Developer@lists.osgeo.org">QGIS-Developer@lists.osgeo.org</a><br />List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank" rel="noopener noreferrer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br />Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank" rel="noopener noreferrer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a></div>
</blockquote>
<p><br /></p>

</body></html>