[Qt-interest] QCompleter drag and drop support within the popup

Felix Nairz felix.nairz at gmail.com
Fri Jan 15 16:07:47 CET 2010


Sorry for the repost, is there really nobody that could suggest any 
solution for this? For me it seems like there is no easy and fast way 
for this, so even a confirmation of my impression would be helpful.
Thanks, Felix

<original message below>

Hi,

I am working on a small application which has a QStringListModel-class 
which provides drag and drop support for other parts of the application. 
The user can drag entries to other widgets which react on the drop 
operations. I have added a QLineEdit to be able to search the 
QStringListModel for specific entries and connected a QCompleter to it. 
The QCompleter uses the QCompleter::PopupCompletion mode (=thus the 
results are shown in a small popup). No problems so far...

Now I have been struggling for hours to get drag and drop directly from 
the popup working but all approaches have failed so far. I want to avoid 
that the user must first choose one entry from the popup and start the 
dragging operation from the "real" entry in my QStringListModel-class in 
a second step.

The QCompleter class offers the completionModel() function which returns 
the model of the popup but there is no function that allows to specify 
an own QAbstractItemModel-based class. Although I can specify whether to 
allow drag operations in the popups QAbstractItemView, this doesn't seem 
to help too because the mime data is not set correctly (although it is 
of the type application/x-qabstractitemmodeldatalist). Maybe I am doing 
something wrong in the dropEvent function of my target but I believe 
it's correct. I have also tried creating a QDrag object manually after 
receiving a pressed-signal from the popup-ItemView, but this didn't work 
as well. Making a detour through the popup-view's - Setting the model 
through the completer->popup()->model() function didn't work either.

Any suggestions on how to solve this issue would be highly appreciated!

Thanks in advance, Felix



More information about the Qt-interest-old mailing list