<?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[Drag and drop between two QTreeWidgets]]></title><description><![CDATA[<p dir="auto">I have the following code and I can't figure out how to get it into the dropEvent() method.  I can click and drag and it enters the dragEnterEvent() and when I move the cursor to the second QTreeWidget, TreeTwo) it enters the dragMoveEvent().  The Item clicked on moves between QTreeWidgets, but the program never enters the dropEvent().</p>
<p dir="auto">@<br />
import sys<br />
import PySide</p>
<p dir="auto">from PySide.QtGui import *<br />
from PySide import QtCore, QtGui<br />
from PySide.QtGui import QMainWindow<br />
from PySide.QtGui import QApplication<br />
from PySide.QtCore import *<br />
from mainwindow_ui import Ui_MainWindow<br />
import platform</p>
<p dir="auto">class MainWindow(QMainWindow, Ui_MainWindow, QDialog):<br />
def <strong>init</strong>(self, parent=None):<br />
super(MainWindow, self).<strong>init</strong>(parent)</p>
<p dir="auto">self.setupUi(self)<br />
<a href="http://self.com" target="_blank" rel="noopener noreferrer nofollow ugc">self.com</a> = communicate()</p>
<h1>self.com.dropinfo.connect(self.TreeTwo.dropEvent(QtCore.Qt.MoveAction))</h1>
<p dir="auto">def somefunc():<br />
print 'Helloooooooooooooooooooooooo'</p>
<p dir="auto">def whollycrap():<br />
print 'Suzannnnnnnnna'</p>
<p dir="auto">QtGui.QTreeWidget.connect(self.TreeTwo, QtCore.SIGNAL('dropEvent()'),somefunc)<br />
QtGui.QTreeWidget.connect(self.TreeTwo, QtCore.SIGNAL('dragMoveEvent()'), whollycrap)<br />
cities = QtGui.QTreeWidgetItem(self.TreeOne)<br />
cities.setText(0, ('cities'))<br />
osloItem = QTreeWidgetItem(cities)<br />
osloItem.setText(0, ('Oslo'))<br />
osloItem.setText(1, ('Yes'))</p>
<p dir="auto">towns = QtGui.QTreeWidgetItem(self.TreeTwo)<br />
towns.setText(0, ('towns'))<br />
vegasItem = QTreeWidgetItem(towns)<br />
vegasItem.setText(0, ('Las Vegas'))<br />
vegasItem.setText(1, ('Yes'))</p>
<p dir="auto">def dragEnterEvent(self, event):<br />
print 'In dragEnterEvent'<br />
event.accept()</p>
<p dir="auto">def dragMoveEvent(self, event):<br />
print 'In dragMoveEvent'<br />
event.setDropAction(QtCore.Qt.MoveAction)<br />
event.accept()</p>
<p dir="auto">def dropEvent(self):<br />
print 'In dropEvent'</p>
<h1>item=self.itemAt(event.pos())</h1>
<h1>if item: self.addHere(item)</h1>
<h1>event.accept()</h1>
<p dir="auto">class communicate(QtCore.QObject):<br />
dropinfo = QtCore.Signal()</p>
<h1>def buildTree(self):</h1>
<h1>cities = QTreeWidgetItem(mainwindow_ui.TreeOne)</h1>
<h1>cities.setText(0, tr('cities'))</h1>
<h1>osloItem = QTreeWidgetItem(cities)</h1>
<h1>osloItem.setText(0, tr('Oslo'))</h1>
<h1>osloItem.setText(1, tr('Yes'))</h1>
<p dir="auto">app = QApplication(sys.argv)<br />
frame = MainWindow()<br />
frame.show()<br />
app.exec_()</p>
<p dir="auto">@</p>
<p dir="auto">David</p>
]]></description><link>https://forum.qt.io/topic/30442/drag-and-drop-between-two-qtreewidgets</link><generator>RSS for Node</generator><lastBuildDate>Tue, 05 May 2026 04:20:28 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/30442.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 08 Aug 2013 02:31:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Drag and drop between two QTreeWidgets on Sat, 10 Aug 2013 18:44:13 GMT]]></title><description><![CDATA[<p dir="auto">Technically you just need the "Using convenience views" part of the document.</p>
<p dir="auto">[quote author="litlbear" date="1376093381"]Just in case, because I didn't state, I am using python and PySide.[/quote]</p>
<p dir="auto">The document still applies, you only have to translate the calls from C++ to python</p>
]]></description><link>https://forum.qt.io/post/190447</link><guid isPermaLink="true">https://forum.qt.io/post/190447</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sat, 10 Aug 2013 18:44:13 GMT</pubDate></item><item><title><![CDATA[Reply to Drag and drop between two QTreeWidgets on Sat, 10 Aug 2013 00:09:41 GMT]]></title><description><![CDATA[<p dir="auto">Just in case, because I didn't state, I am using python and PySide.</p>
]]></description><link>https://forum.qt.io/post/190413</link><guid isPermaLink="true">https://forum.qt.io/post/190413</guid><dc:creator><![CDATA[litlbear]]></dc:creator><pubDate>Sat, 10 Aug 2013 00:09:41 GMT</pubDate></item><item><title><![CDATA[Reply to Drag and drop between two QTreeWidgets on Fri, 09 Aug 2013 23:10:31 GMT]]></title><description><![CDATA[<p dir="auto">The documentation is quite intense for a newbie.  Ok, so I have to use a mime-encoded datatype to transfer/import from one QtreeWidget to another?</p>
<p dir="auto">Still not sure how to do that.  Any further assistance?</p>
]]></description><link>https://forum.qt.io/post/190412</link><guid isPermaLink="true">https://forum.qt.io/post/190412</guid><dc:creator><![CDATA[litlbear]]></dc:creator><pubDate>Fri, 09 Aug 2013 23:10:31 GMT</pubDate></item><item><title><![CDATA[Reply to Drag and drop between two QTreeWidgets on Thu, 08 Aug 2013 20:02:58 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Since you're using QTreeWidget did you check this "document":<a href="http://qt-project.org/doc/qt-4.8/model-view-programming.html#using-drag-and-drop-with-item-views" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-4.8/model-view-programming.html#using-drag-and-drop-with-item-views</a></p>
]]></description><link>https://forum.qt.io/post/190215</link><guid isPermaLink="true">https://forum.qt.io/post/190215</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 08 Aug 2013 20:02:58 GMT</pubDate></item><item><title><![CDATA[Reply to Drag and drop between two QTreeWidgets on Thu, 08 Aug 2013 15:49:44 GMT]]></title><description><![CDATA[<p dir="auto">Yes, sorry about that, I put that in and I still can't get to the dropEvent() when I drop on the second QTreeWidget.<br />
@<br />
def dropEvent(self, event):<br />
print 'In dropEvent'<br />
@</p>
]]></description><link>https://forum.qt.io/post/190184</link><guid isPermaLink="true">https://forum.qt.io/post/190184</guid><dc:creator><![CDATA[litlbear]]></dc:creator><pubDate>Thu, 08 Aug 2013 15:49:44 GMT</pubDate></item><item><title><![CDATA[Reply to Drag and drop between two QTreeWidgets on Thu, 08 Aug 2013 09:35:14 GMT]]></title><description><![CDATA[<p dir="auto">aren't you missing the "event" parameter in your drop event handler?</p>
]]></description><link>https://forum.qt.io/post/190123</link><guid isPermaLink="true">https://forum.qt.io/post/190123</guid><dc:creator><![CDATA[raven-worx]]></dc:creator><pubDate>Thu, 08 Aug 2013 09:35:14 GMT</pubDate></item></channel></rss>