Hello Team,
I have two combo boxes in my application but one isn’t working. I copy/pasted the part thats not working below with the error message. what am i doing wrong?
Error message received:
TypeError: arguments did not match any overloaded call:
addItem(self, text: Optional[str], userData: Any = None): argument 1 has unexpected type ‘list’
addItem(self, icon: QIcon, text: Optional[str], userData: Any = None): argument 1 has unexpected type ‘list’
import os
import sys
import openpyxl
from PyQt6.QtWidgets import (QApplication, QLabel, QWidget, QMainWindow, QComboBox, QVBoxLayout)
class Testing(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("Script testing")
self.filePath = "projectAssessment.xlsx"
self.rootLayout = QVBoxLayout(self) # Parent layout
self.searchBy = QLabel("Learing ComboBox")
self.rootLayout.addWidget(self.searchBy)
self.setLayout(self.rootLayout)
self.comboList1 = self.getComboboxListing()
self.cbo2 = QComboBox()
self.cbo2.addItem(self.comboList1)
self.rootLayout.addWidget(self.cbo2)
def getComboboxListing(self):
self.list1 = [] # create list
self.workBook = openpyxl.load_workbook(self.filePath, read_only=True)
self.sheet = self.workBook.worksheets[0] # Get the first sheet
for rec in self.sheet[1]:
self.list1.append(rec.value)
return self.list1
#########################################################################
app = QApplication(sys.argv)
rootWindow = Testing()
rootWindow.show()
sys.exit(app.exec())