<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">HI Matteo,</div><div class=""><br class=""></div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On 10 May 2016, at 18:14, matteo <<a href="mailto:matteo.ghetta@gmail.com" class="">matteo.ghetta@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hi devs,<br class=""><br class="">I'm struggling with a maybe simple issue..<br class=""><br class="">In a plugin I have added a QgsFieldExpressionWidget connected to a QgsMapLayerComboBox..<br class=""><br class="">What I am currently trying to do without any result is to get a list of the field values filtered with the result of the expression added<br class=""><br class="">In a *normal* QgsFieldComboBox I achive it as follows:<br class=""><br class=""># QgsMapLayerComboBox<br class="">lay1 = self.Field1.layer()<br class=""># QgsFieldComboBox<br class="">lay1_f = self.Field1.currentField()<br class=""><br class=""><br class=""># create the list of the selected fields<br class="">f1 = []<br class="">    for i in lay1.getFeatures():<br class="">    f1.append(i[lay1_f])<br class=""></div></div></blockquote><div><br class=""></div><div>You’re doing feature[field_name] which is fine, but doing feature[expression] is not valid because there is no index corresponding.</div><div>You need to evaluate the expression.</div><div><br class=""></div><div>So basically, just test if currentField returns an expression or not.</div><div>If not, keep your line.</div><div>If it is, evaluate the expression </div><div><a href="https://qgis.org/api/classQgsExpression.html#a279785f0a59cc4ac977022797599bdc6" class="">https://qgis.org/api/classQgsExpression.html#a279785f0a59cc4ac977022797599bdc6</a></div><div><br class=""></div><div>I hope this helps!</div><div><br class=""></div><div>Denis</div></div></body></html>