<div dir="ltr"><div class="gmail_extra">Hello,<br><br>I am trying to setup a value relation edittype by pyqgis. I can use setWidgetType but then, none of the following seem to work:<br><pre style="" class=""><code><span class="">vlayer.valueRelation</span><span class="">(</span><span class="">index</span><span class="">).</span><span class="">mLayer </span><span class="">=</span><span class=""> target_layer</span><span class="">.</span><span class="">id</span><span class="">()</span><span class="">
vlayer</span><span class="">.</span><span class="">valueRelation</span><span class="">(</span><span class="">index</span><span class="">).</span><span class="">mKey </span><span class="">=</span><span class=""> key_field
vlayer</span><span class="">.</span><span class="">valueRelation</span><span class="">(</span><span class="">index</span><span class="">).</span><span class="">mValue </span><span class="">=</span><span class=""> value_field
vlayer</span><span class="">.</span><span class="">valueRelation</span><span class="">(</span><span class="">index</span><span class="">).</span><span class="">mAllowNull </span><span class="">=</span><span class=""> </span><span class="">True</span><span class="">
vlayer</span><span class="">.</span><span class="">valueRelation</span><span class="">(</span><span class="">index</span><span class="">).</span><span class="">mOrderByValue</span></code></pre>I also asked this question at GIS stackexchange (<a href="http://gis.stackexchange.com/questions/204175/how-to-set-and-configure-a-value-relation-edittype-in-qgis-2-14">http://gis.stackexchange.com/questions/204175/how-to-set-and-configure-a-value-relation-edittype-in-qgis-2-14</a>) but no responses so far. <br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Does anyone know how to configure the value relation from python?<br><br></div><div class="gmail_extra">Thanks,<br></div><div class="gmail_extra">Josef<br></div></div>