I want to use QTableWidgetItem but something wrong.. I think the algorithm is as follows.
push bottom("apply") -> change Table widget items (But nothing change...)
here my python code... Please pay attention to the comments.
# -*- coding: utf-8 -*-
[..import..]
class UserModel(QStandardItemModel):
[..item modeling for combobox..]
class Tab_1(QWidget):
def __init__(self, API, parent=None):
super(Tab_1, self).__init__(parent=parent)
self.API = API
self.ipaddr = []
self.init_widget()
def init_widget(self):
[..GropBox & Layout define..]
#### ComboBox define
manufacturer = ["a", "b", "c"]
combo_model = UserModel(manufacturer)
combobox = QComboBox()
combobox.setModel(combo_model)
combobox.currentTextChanged.connect(self.select_manufacturer)
[..pushbotton define..]
pushbottom_list[1].released.connect(self.apply) ## connect Slot
[..combo box event..]
#### Push bottom Event
def apply(self): ## apply button slot
main = main1()
print("apply")
item = ["a", "b", "c", "d", "1", "2"]
main.table_add_item(item) ## call
main window class!!
class main1(QMainWindow):
def __init__(self):
super(QMainWindow, self).__init__()
self.initUI()
def initUI(self):
[..menuBar define..]
self.table = QTableWidget(self)
self.table.setGeometry(0, 21, 300, 700)
self.table.setRowCount(200)
self.table.setColumnCount(1)
self.tbw = QTabWidget(self)
self.tbw.setGeometry(300,21,400,500)
self.tbw.addTab(Tab_1("API"), "Search API")
[..layout define..]
def status_msg(self, msg):
self.sb.showMessage(msg)
def table_add_item(self, item): ## setItem...
for i in range(len(item)):
print(item[i]) ## work
self.table.setItem(i, 0, QTableWidgetItem(item[i])) ## Not Working!!! and nothing changed......
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = main1()
ex.show()
sys.exit(app.exec_())