`TypeError: arguments did not match any overloaded call:`
Unsolved
Qt for Python
-
wrote on 16 Aug 2021, 18:02 last edited by Caeden
labelLis = [] self.comboList = [] self.removeList = [] for i, value in enumerate(_FRIEND_COLLECTION.find_one({'from': self.username[0]}), start=-2): if value in ['from', '_id']: continue labelLis.append(QLabel(value)) self.comboList.append(QPushButton(f"Dm {value}")) self.removeList.append(QPushButton(f"Remove {value}")) formLayout.addRow(labelLis[i], self.removeList[i], self.comboList[i])
gives
Traceback (most recent call last): File "c:\Users\caede\Desktop\all-cura\curabitur\phases\viewfriends.py", line 38, in init_Ui formLayout.addRow(labelLis[i], self.removeList[i], self.comboList[i]) TypeError: arguments did not match any overloaded call: addRow(self, QWidget, QWidget): too many arguments addRow(self, QWidget, QLayout): argument 2 has unexpected type 'QPushButton' addRow(self, str, QWidget): argument 1 has unexpected type 'QLabel' addRow(self, str, QLayout): argument 1 has unexpected type 'QLabel' addRow(self, QWidget): too many arguments addRow(self, QLayout): argument 1 has unexpected type 'QLabel'
How can I make it accept 3/possibly more arguments? Im using scroll area btw.
ps:
formLayout =QFormLayout() groupBox = QGroupBox("There are your friends")
and:
groupBox.setLayout(formLayout) scroll = QScrollArea() scroll.setWidget(groupBox) scroll.setWidgetResizable(True) scroll.setFixedHeight(400) layout = QVBoxLayout(self) layout.addWidget(scroll)
-
Hi,
If you want to put more than one widget on a row, put them in a horizontal layout and add the layout to the QFormLayout.
-
labelLis = [] self.comboList = [] self.removeList = [] for i, value in enumerate(_FRIEND_COLLECTION.find_one({'from': self.username[0]}), start=-2): if value in ['from', '_id']: continue labelLis.append(QLabel(value)) self.comboList.append(QPushButton(f"Dm {value}")) self.removeList.append(QPushButton(f"Remove {value}")) formLayout.addRow(labelLis[i], self.removeList[i], self.comboList[i])
gives
Traceback (most recent call last): File "c:\Users\caede\Desktop\all-cura\curabitur\phases\viewfriends.py", line 38, in init_Ui formLayout.addRow(labelLis[i], self.removeList[i], self.comboList[i]) TypeError: arguments did not match any overloaded call: addRow(self, QWidget, QWidget): too many arguments addRow(self, QWidget, QLayout): argument 2 has unexpected type 'QPushButton' addRow(self, str, QWidget): argument 1 has unexpected type 'QLabel' addRow(self, str, QLayout): argument 1 has unexpected type 'QLabel' addRow(self, QWidget): too many arguments addRow(self, QLayout): argument 1 has unexpected type 'QLabel'
How can I make it accept 3/possibly more arguments? Im using scroll area btw.
ps:
formLayout =QFormLayout() groupBox = QGroupBox("There are your friends")
and:
groupBox.setLayout(formLayout) scroll = QScrollArea() scroll.setWidget(groupBox) scroll.setWidgetResizable(True) scroll.setFixedHeight(400) layout = QVBoxLayout(self) layout.addWidget(scroll)
wrote on 16 Aug 2021, 18:08 last edited by eyllanesc@Caeden A QFormLayout has 2 columns, how would the 3 widgets (QLabel and 2 QPushButtons) be placed in the 2 columns?
If you want more columns then use QGridLayout:
gridLayout = QGridLayout() row = 0 for i, value in enumerate( _FRIEND_COLLECTION.find_one({"from": self.username[0]}), start=-2 ): if value in ["from", "_id"]: continue label = QLabel(value) button1 = QPushButton(f"Dm {value}") button2 = QPushButton(f"Dm {value}") gridLayout.addWidget(label, row, 0) gridLayout.addWidget(button1, row, 1) gridLayout.addWidget(button2, row, 2) row += 1
-
wrote on 16 Aug 2021, 18:39 last edited by
@eyllanesc
thanks, i'll try this - I wasn't aware that you could only place 2 -
Then please read the QFormLayout documentation, you'll see what is possible.
1/6