Hi there
PyQt is not available as tag, but this should be a simple question anyway:
- drag & drop: from QListWidget to QListwidget
- pushButton action: inserts chosen items from second QListWidget into QTableWidget
But: when i run my code - most of the time the chosen items are inserted twice into my QTableWidget,
sometimes the code runs like expected - and i can't figure out why.
Of course i tried a "print(num)", and the added really occurs twice, for example:
(0) ListEdit
(0) ListEdit
(1) TextEdit
(1) TextEdit
... a.s.o.
Here's the snippet:
vheader = self.tableWidget.verticalHeader()
r_count = self.tableWidget.rowCount()
c_count = self.tableWidget.columnCount()
for num in range(self.listWidget_3.count()):
name = self.listWidget_3.item(num).text()
if name == 'LineEdit':
this = r_count
that = (c_count -1)
line_comboBox = QComboBox()
new_line = QLineEdit()
self.tableWidget.insertRow(this)
self.tableWidget.setCellWidget(this, that -1, line_comboBox)
self.tableWidget.setCellWidget(this, that, new_line)
vheader.setSectionResizeMode(this, QHeaderView.ResizeToContents)
elif ......:
Err.. working on PyCharm. PyQt 5.13, Python 3.7.4 - if you'd need any further information: let me know.