Unsolved Get all items from within groupbox of pyqt
-
I have a groupbox that has 4 comboboxes within it. I want to say in my code something along the lines of
for i in self.ui.all_of_the_combo_boxes: do something
I am aware of the .getChildren() method, but my problem with that is that I have about 6 other comboboxes throughout my gui. So I would be gettingback 10-12 values when I only need 4. On top of that it returns the comboboxes as
[<PySide2.QtWidgets.QComboBox(0xfcbfad0, name="comb_pow_m") at 0x10C8F268>,
rather than just the values.
Or if there is just a way to get all the text of the items. For example something like
children = self.findChildren(QComboBox) print(children.currentText())
-
Hi,
You can call findChildren on the combo box you are interested in.
-
I have a groupbox that has 4 comboboxes within it.
If I understand you right, it is from a groupbox (
QGroupBox
) that you want to find child comboboxes? Assuming so, depending on what yourself
is, you should be going:childCombos = self.someGroupBox.findChildren(QComboBox) for childCombo in childCombos: print(childCombo.currentText())
-
-
@poordev123
Just so you know: it'sQObject::findChildren()
so you can actually call it on anyQObject
, and that includes any and allQWidget
s.QGroupBox
is aQWidget
itself, and there are other such "container" widgets for which this works.