from PyQt5.QtWidgets import QMainWindow, QListWidget, QApplication class MainWindow(QMainWindow): def __init__(self): super().__init__() # Create QListWidget self.list_widget = QListWidget(self) # Add items self.list_widget.addItem('Item 1') self.list_widget.addItem('Item 2') self.list_widget.addItem('Item 3') # Set layout and properties self.setCentralWidget(self.list_widget) self.setGeometry(100, 100, 250, 150) self.setWindowTitle('List Widget') # Create PyQt5 Application app = QApplication([]) window = MainWindow() window.show() app.exec_()
from PyQt5.QtGui import Qt from PyQt5.QtWidgets import QMainWindow, QListWidget, QApplication class MainWindow(QMainWindow): def __init__(self): super().__init__() # Create QListWidget self.list_widget = QListWidget(self) # Add items self.list_widget.addItem('Item 1') self.list_widget.addItem('Item 2') self.list_widget.addItem('Item 3') # Enable drag and drop self.list_widget.setDragEnabled(True) self.list_widget.setDropIndicatorShown(True) self.list_widget.setSelectionMode(QListWidget.ExtendedSelection) # Set layout and properties self.setCentralWidget(self.list_widget) self.setGeometry(100, 100, 250, 150) self.setWindowTitle('Drag and Drop List') # Create PyQt5 Application app = QApplication([]) window = MainWindow() window.show() app.exec_()Package Library: PyQt5.