<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QListWidget drag and drop does not work]]></title><description><![CDATA[<p dir="auto">I am trying to implement in my project a QListWidget with the possibility of moving elements by drag and drop</p>
<p dir="auto">I try to integrate it into the project in the simplest way without success, while outside I have no problem executing it Here is its implementation:</p>
<p dir="auto"><a href="http://priorityContainer.py" target="_blank" rel="noopener noreferrer nofollow ugc">priorityContainer.py</a>:</p>
<pre><code>class priorityContainer(QListWidget):
def __init__(self):
    super().__init__()
    self.setIconSize(QSize(124, 124))
    self.setDragDropMode(QAbstractItemView.InternalMove)
    self.setDefaultDropAction(Qt.MoveAction) 
    self.setSelectionMode(QAbstractItemView.ExtendedSelection)
    self.setAcceptDrops(True)
    self.setDragEnabled(True)

    for i in range(12):
        QListWidgetItem( 'Item '+str(i), self)
</code></pre>
<p dir="auto">main_interface.py:</p>
<pre><code>from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import sys, os

from ressource.ResizableWindows import ResizableWindows
from ressource.Point import paintDot
from ressource.interface import tab_widget
from ressource.interface.error import messagederreur
from ressource.interface import priorityContainer

from ressource.camLabel import camLabel
from ressource.ToolsBar import toolsBar
import serveur.xmlrpc_server as xmlrpc_server
import memoire.XML_manager as XML_manager
import memoire.modele as modele
import socket

class UI_main(QMainWindow):
    def __init__(self):
         super(UI_main, self).__init__()
    
         qInstallMessageHandler(messagederreur)
         self.threadpool = QThreadPool()
    
         logo = QPixmap("Ressource/navigation/logo_icon.png")
         self.setWindowIcon(QIcon(logo))
    
         self.server_thread = xmlrpc_server.xmlrpc_server()
         self.server_thread.vid_thread.signals.connection.connect(self.vid_thread_connection)
         self.server_thread.signals.cmdSignal.connect(self.setCmdData)
         self.server_thread.vid_thread.signals.cmdSignal.connect(self.setCmdData)
    
         self.threadpool.start(self.server_thread)
         self.setupUi()
         self.show() 
         [...]

    def setupUi(self):
         self.centralwidget = QWidget(self)
         self.mainVcontainer = QVBoxLayout(self.centralwidget)
    
         self.detectionContainer = QWidget()
         self.detectionHContainer = QHBoxLayout(self.detectionContainer)
         self.dataCmdContainer = QVBoxLayout()
         self.dataOrderHContainer = QHBoxLayout()
         [...]
         self.priorityContainer = priorityContainer.priorityContainer()
         self.dataOrderHContainer.addLayout(self.dataVContainer)
         self.dataOrderHContainer.addWidget(self.priorityContainer)
                 
         self.dataCmdContainer.addLayout(self.dataOrderHContainer)   
         [...] 
         self.detectionHContainer.addLayout(self.dataCmdContainer)
    
         [...]
         self.mainVcontainer.addWidget(self.detectionContainer)
         self.setCentralWidget(self.centralwidget)
</code></pre>
<p dir="auto"><a href="http://main.py" target="_blank" rel="noopener noreferrer nofollow ugc">main.py</a>:</p>
<p dir="auto">from ressource.interface.main_interface import UI_main<br />
from ressource.interface.Tuto import UI_tuto<br />
import memoire.modele as modele<br />
[...]</p>
<p dir="auto">class Contr```<br />
oller:<br />
def <strong>init</strong>(self):</p>
<pre><code>    modele.init()
    self.parameters = modele.model.globalParameters 
    [...]
def show_main(self):
    [...]
    self.parameters.save_parameters()
    self.UI_main = UI_main()
    [...]
[...]
</code></pre>
<p dir="auto">def main():</p>
<pre><code>app = QApplication(sys.argv)
controller = Controller()

myappid = 'mycompany.myproduct.subproduct.version'  # arbitrary string
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)

if controller.parameters.guide_done == 0:
    controller.show_tuto()
    sys.exit(app.exec_())
else:
    controller.show_main()
    sys.exit(app.exec_())
</code></pre>
<pre><code>if __name__ == '__main__':
    main()
</code></pre>
<p dir="auto">I am also having problems with the QFileDialog where I have to use QFileDialog.DontUseNativeDialog to not crash the program</p>
]]></description><link>https://forum.qt.io/topic/118919/qlistwidget-drag-and-drop-does-not-work</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 15:53:18 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/118919.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 11 Sep 2020 13:29:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QListWidget drag and drop does not work on Mon, 21 Sep 2020 13:39:38 GMT]]></title><description><![CDATA[<p dir="auto">I have solved my problem by adding these lines before any other imports where I import my pyrealsense2 librairies:</p>
<pre><code>import sys
sys.coinit_flags = 2
import pythoncom
</code></pre>
]]></description><link>https://forum.qt.io/post/618098</link><guid isPermaLink="true">https://forum.qt.io/post/618098</guid><dc:creator><![CDATA[sam37120]]></dc:creator><pubDate>Mon, 21 Sep 2020 13:39:38 GMT</pubDate></item><item><title><![CDATA[Reply to QListWidget drag and drop does not work on Mon, 21 Sep 2020 18:53:04 GMT]]></title><description><![CDATA[<p dir="auto">Glad you found a solution and thanks for sharing !</p>
<p dir="auto">Can you explain a bit more about it ?</p>
]]></description><link>https://forum.qt.io/post/618155</link><guid isPermaLink="true">https://forum.qt.io/post/618155</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Mon, 21 Sep 2020 18:53:04 GMT</pubDate></item><item><title><![CDATA[Reply to QListWidget drag and drop does not work on Mon, 21 Sep 2020 13:39:38 GMT]]></title><description><![CDATA[<p dir="auto">I have solved my problem by adding these lines before any other imports where I import my pyrealsense2 librairies:</p>
<pre><code>import sys
sys.coinit_flags = 2
import pythoncom
</code></pre>
]]></description><link>https://forum.qt.io/post/618098</link><guid isPermaLink="true">https://forum.qt.io/post/618098</guid><dc:creator><![CDATA[sam37120]]></dc:creator><pubDate>Mon, 21 Sep 2020 13:39:38 GMT</pubDate></item><item><title><![CDATA[Reply to QListWidget drag and drop does not work on Fri, 18 Sep 2020 13:16:19 GMT]]></title><description><![CDATA[<p dir="auto">Here is a minimal version, the problem seems to come from the realsense library, without its, DAD works</p>
<p dir="auto"><a href="http://priorityContainer.py" target="_blank" rel="noopener noreferrer nofollow ugc">priorityContainer.py</a>:</p>
<pre><code>class priorityContainer(QListWidget):
def __init__(self):
    super().__init__()
    self.setIconSize(QSize(124, 124))
    self.setDragDropMode(QAbstractItemView.InternalMove)
    self.setDefaultDropAction(Qt.MoveAction) 
    self.setSelectionMode(QAbstractItemView.ExtendedSelection)
    self.setAcceptDrops(True)
    self.setDragEnabled(True)

    for i in range(5):
        QListWidgetItem( 'Item '+str(i), self)
</code></pre>
<p dir="auto">main_interface.py:</p>
<pre><code>from PyQt5.QtWidgets import *
import traceback, sys, os
import pyrealsense2 as rs
from ressource.interface import priorityContainer


class UI_main(QMainWindow):
    def __init__(self):
        super(UI_main, self).__init__()

        self.setupUi()
        self.show()

    def setupUi(self):
        self.centralwidget = QWidget(self)
        self.mainVcontainer = QVBoxLayout(self.centralwidget)

        self.listWidget = priorityContainer.priorityContainer()

        self.mainVcontainer.addWidget(self.listWidget)
        self.setCentralWidget(self.centralwidget)

    def root_path(self):
        return os.path.abspath(os.sep)


if __name__ == "__main__":
    app = QApplication(sys.argv)
    ui = UI_main()
    sys.exit(app.exec_())
</code></pre>
]]></description><link>https://forum.qt.io/post/617686</link><guid isPermaLink="true">https://forum.qt.io/post/617686</guid><dc:creator><![CDATA[sam37120]]></dc:creator><pubDate>Fri, 18 Sep 2020 13:16:19 GMT</pubDate></item><item><title><![CDATA[Reply to QListWidget drag and drop does not work on Tue, 15 Sep 2020 18:08:13 GMT]]></title><description><![CDATA[<p dir="auto">Hence my suggestion of providing a minimal runnable example. Writing it may help you find the actual issue you are having.</p>
]]></description><link>https://forum.qt.io/post/617249</link><guid isPermaLink="true">https://forum.qt.io/post/617249</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 15 Sep 2020 18:08:13 GMT</pubDate></item><item><title><![CDATA[Reply to QListWidget drag and drop does not work on Tue, 15 Sep 2020 12:24:53 GMT]]></title><description><![CDATA[<p dir="auto">I agree unfortunately the problem is there, if I use QListWidget in an isolate way I have no problem, it's context related. For example by removing the imports of other widgets, (and by commenting a good part of the text), I have no problem, it is enough to put these imports again and the problem returns.</p>
<p dir="auto">PyQT 5.13.0<br />
Windows 10 1909 18363.1082</p>
]]></description><link>https://forum.qt.io/post/617186</link><guid isPermaLink="true">https://forum.qt.io/post/617186</guid><dc:creator><![CDATA[sam37120]]></dc:creator><pubDate>Tue, 15 Sep 2020 12:24:53 GMT</pubDate></item><item><title><![CDATA[Reply to QListWidget drag and drop does not work on Sat, 12 Sep 2020 07:53:12 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Which version of PyQt5 ?<br />
On which Windows version ?</p>
<p dir="auto">Please provide a minimal runnable example that shows the behaviour your seeing.</p>
]]></description><link>https://forum.qt.io/post/616856</link><guid isPermaLink="true">https://forum.qt.io/post/616856</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sat, 12 Sep 2020 07:53:12 GMT</pubDate></item></channel></rss>