<div>Howdy,</div>
<div> </div>
<div>I'm a PyQt newb but fairly experienced with Python. So far I'm very impressed with PyQt and have been able to get quite a sophisticated app up and running in a short period of time. However I've hit a road block that so far I have not been able to figure out.</div>
<div> </div>
<div>I am using <span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 13px Tahoma; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0">PyQt4 (Qt 4.4.3 with Python 2.6) on Windows XP. I am trying to drag treeWidget info from one widget to another. The target widget will likely be a modified tree widget as I need to combine a tree with a table to get the proper data mix I need. </span></div>
<div><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 13px Tahoma; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0"></span> </div>
<div><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 13px Tahoma; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0">My first attempt was simply doing this:</span></div>
<div><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 13px Tahoma; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0"></span> </div>
<div><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 13px Tahoma; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0">
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">itemData = event.mimeData().retrieveData("application/x-qabstractitemmodeldatalist", QtCore.QVariant.List)</blockquote>
<div> </div>
<div>However that apparently accessed a protected C++ function which quickly threw an exception. </div>
<div> </div>
<div>So then I tried to pull serialized data out using the data() function which returned an empty set. Then I tried to pull data out using the items() function passing in the mimeData object. Here is an example that I used to try and get this working with another widget type. </div>
<div> </div>
<div><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 13px Tahoma; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0">
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 13px Tahoma; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0">class ListBoxDnD(QListWidget):<br>
def __init__(self, parent):<br>QListWidget.__init__(self, parent)<br>self.setDragEnabled(True)<br>self.setAcceptDrops(True)<br>...<br><br>def dropEvent(self, e):<br>print self.items(e.mimeData())</span></blockquote></span></div>
<div><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 13px Tahoma; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0"></span> </div>
<div><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 13px Tahoma; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0">This also returned an empty set. I thought if anything should translate the data for me, this should do it. I know the data is there because I can see the drag and drop working as data items are being correctly added to the target widget. However the same mimeData is returning no data when I try to access it directly. I can't figure that out. </span></div>
<div><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 13px Tahoma; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0"></span> </div>
<div><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 13px Tahoma; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0">I was able to find a work-around by overriding the drop function and just grabbing the selected items from the source widget directly. This actually works a little better than the default drag/drop behavior because I need the selected tree items plus all the child items with a little extra data pulled from a database. However at some point I may need to use the MimeData functionality as it was originally intended, so hopefully someone will know how to get this to work correctly.</span></div>
<div><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 13px Tahoma; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0"></span> </div>
<div>Thanks ahead of time,</div>
<div>Marc</div>
<div><span class="Apple-style-span" style="WORD-SPACING: 0px; FONT: 13px Tahoma; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 1px; -webkit-border-vertical-spacing: 1px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0"></span> </div>
<div> </div></span></div>