ich baue über eine Schleife über ein Array/eine Liste und mit mehreren if-elif-Anweisungen ein Design auf.
Abhängig vom Wert einer SelectionBox (MapFeature),
sollen sich die Werte einer anderen SelectionBox (Status) ergeben.
Dabei arbeite ich mit dem .connect()-Befehl und
möchte das Signal mit .emit() abfangen.
Code: Alles auswählen
if group_name == "Map Feature":
# creates all choices for selection
for idx, item in enumerate(items[1]):
self.combo_box_map_feature.addItem(item)
# set listener for event handling to selection box
self.combo_box_map_feature.activated.connect(self.feature_type_listener)
# add complete Widget to Map Feature element
layout_vbox_map_feature.addWidget(self.combo_box_map_feature)
# create GroupBox for Map Feature Selection
map_feature_group_box = QGroupBox(group_name)
map_feature_group_box.setLayout(layout_vbox_map_feature)
# add GroupBox to outer layout
layout_grid_radio_groups.addWidget(map_feature_group_box)
elif group_name == "Validation Status":
for status_type in validation_lst:
if status_type[0] == self.combo_box_map_feature.activated.emit():
self.combo_box_status.addItem(status_type[1])
# add complete Widget to Status element
layout_vbox_status.addWidget(self.combo_box_status)
# create GroupBox for Status selection
status_group_box = QGroupBox(group_name)
status_group_box.setLayout(layout_vbox_status)
# add GroupBox to outer layout
layout_grid_radio_groups.addWidget(status_group_box)
Code: Alles auswählen
def feature_type_listener(self):
feature_type = self.sender().currentText()
# hide all group_boxes
self.group_box_sign.hide()
self.group_box_pole.hide()
self.group_box_rb.hide()
self.group_box_sl.hide()
self.group_box_ee.hide()
self.group_box_bridge.hide()
# resize window
self.widget.resize(self.widget.minimumSizeHint())
self.resize(self.minimumSizeHint())
# set combo_boxes and value line to default
self.combo_box_lane_sign_type.setCurrentIndex(0)
self.combo_box_warning_sign_type.setCurrentIndex(0)
self.sign_val_line_edit.text() == None
# show selected group box/feat_type
if feature_type == "TRAFFIC SIGN":
self.group_box_sign.show()
elif feature_type == "POLE":
self.group_box_pole.show()
elif feature_type == "ROADSIDE BARRIER":
self.group_box_rb.show()
elif feature_type == "SPECIAL LANE TYPE":
self.group_box_sl.show()
elif feature_type == "EXIT/ENTRY":
self.group_box_ee.show()
elif feature_type == "BRIDGE":
self.group_box_bridge.show()
allerdings keine Auswahlmöglichkeiten in der Status-SelectionBox.
Mit anderen Wegen bin ich auch nicht voran gekommen,
daher dann die Idee mit dem .emit()-Befehl.
Das Problem jetzt: das Prorgamm stürzt beim Öffnen ab.
Fehlermeldung:
Ehrlicherweise ist mir das .activated von der Funktionsweise bzw. vom Sinn meiner Verwendung nicht klar.File "C:/Users/MATTDOE/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\video_uav_tracker\issue_dialog.py", line 251, in __init__
if status_type[0] == self.combo_box_map_feature.activated.emit():
TypeError: activated(self, int) signal has 1 argument(s) but 0 provided
Ohne .activated, kann ich aber irgendwie auch schon den Listener/die Überwachung starten.
Daher habe ich nach Online-Recherche das einfach hinzugefügt.
Damit lief dann der Code, bis ich das mit .emit() nun einfügen wollte.
Auch mit der Fehlermeldung konnte ich dann nichts mehr anfangen.
Ist .activated() nicht einfach nur der Funktionsaufruf/die Aktion, die den Listener startet?
Brauche ich das beim Wert abfragen überhaupt?
Kann ich den überhaupt von einer SelectionBox den aktuellen Wert ermitteln und verwenden (außerhalb der Methode "feature_type_listener".
Vielen Dank für euer Hilfe

Matze