1

when I drag a row to place it in the same place somehow this causes a bug to happen and remove content of this dragged row! is there any fix to keep the data of this dragged row.

  1. I try to drag first row "text 0" to the same place. enter image description here

  2. Now the first row vanished and turned into empty item ! I don't want to lose this text. enter image description here

import sys
from PySide2.QtWidgets import QWidget, QLabel, QApplication, QVBoxLayout,QListWidget, QListWidgetItem, QAbstractItemView, QLineEdit, QComboBox

class main(QWidget):
    def __init__(self):
        super().__init__()
        self.setStyleSheet('*{font-size:25px;}')

        self.layout = QVBoxLayout()
        table = QListWidget()
        table.setDragDropMode(QAbstractItemView.InternalMove)

        for i in range(5):
              item = QListWidgetItem()
              widget = QLabel(f'textt {i}')
              table.addItem(item)
              table.setItemWidget(item, widget)

        self.layout.addWidget(table)
        self.setLayout(self.layout)


class app(QApplication):
    def __init__(self):
        super().__init__()
        self.main = main()
        self.main.show()

app = app()
sys.exit(app.exec_())
math4end
  • 23
  • 4

0 Answers0