3

in Qt Designer there is the possibility to use directly QGIS custom widgets.

In the UI I added a QgsMapLayerComboBox (to get the layers added in the legend) and a QgsDataDefinedButton.

What I would like to do is to connect the QgsDataDefinedButton to the QgsMapLayerComboBox so that the QgsDataDefinedButton should be updated with the fields of the selected layer of the QgsMapLayerComboBox.

While connecting QgsMapLayerComboBox to a QgsFieldComboBox or a QgsFieldExpressionComboBox is not a problem through the singal - slot combination:

layerCHanged(QgsMapLayer*) -> setLayer(QgsMapLayer*)

I'm not able to to that with the QgsDataDefinedButton.

Any hints?

3

Thanks to the qgis-dev mailing list and to Denis Rouzaud, this is the answer..

class MyDialogClass(UiClass):
  def __init__(self):
    self.setupUi()
    self.myLayerComboBox.layerChanged.connect(self.myConnectMethod)

  @pyqtSlot(QgsVectorLayer)
  def myConnectMethod(self, layer)
    self.myDataDefinedButton.init(layer, .....)

so the link between the 2 widgets could not be made through Qt Designer and has to be written within the code.

Hope this could help someone else.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.