Re: [Interest] QListView: drag custom item

2016-08-17 Thread André Somers



Op 16/08/2016 om 09:26 schreef Frank Rueter | OHUfx:

Hi,

I am trying to get drag to work between two QListViews using a 
custom item.
I can't find the info I need online other than this document 
 which helped a 
little bit but now I'm stuck.


Drag from one QListView to another works fine when I use a 
QStandardItem to hold my data, but when I use a custom item I run into 
trouble, because the receiving model/view creates a QStandardItem when 
the incoming custom items are dropped.


Ideally I could tell the receiving model to use my custom item as the 
default item and otherwise just do it's thing, but I suppose it won't 
be that easy?!
I have played around with the receiving model's dropMimeData() and 
insertRows() methods but can't work out how to read the incoming data 
to then insert a custom item into the receiving model manually.
In QAbstractItemModel.dropMimeData() I tried reading 
mimeData.data('application/x-qabstractitemmodeldatalist'), but that 
returns a byte stream that I don't know how to handle.


Do I have to re-implement the sender's drag data as well to send the 
custom item in the first place?


It seems that everything works out of the box except the creation of 
the QStandardItem upon drop, rather than my custom item, so I am 
hoping I don't have to re-invent the (drag) wheel just to get 
that one part right?!


Any advise would be greatly appreciated.

Thanks,
frank



What kind of models are you using behind these views? Custom models or 
QStandardItemModel instances? To me, it sounds like the latter?


André
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QListView: drag custom item

2016-08-17 Thread Frank Rueter | OHUfx
Thanks, but that still causes the default drag behaviour to drop a 
QStandardItem rather than the subclassed custom item that was dragged. 
It's not the data that is the issue but the class type itself.


I have now refactored my code to use QStdandardItem instead of a custom 
one which makes it all work, but I'd still be quite interested to know 
the best way to do this (drag a custom item between two QListViews 
in the same application).



Cheers,
frank

On 17/08/16 8:24 PM, Viktor Engelmann wrote:


The QStandardItem seems to be used to limit the drag to files, 
images, text etc. so that you can drag & drop from and to external 
applications (which is not possible for general objects).


http://doc.qt.io/qt-4.8/qstandarditem.html#subclassing says you should 
subclass QStandardItem and override read and write or data and 
setData. That is probably used to marshal and unmashal the objects, to 
make them compatible to text, which can be passed to and from external 
applications.


Viktor


On 16.08.2016 23:56, Frank Rueter | OHUfx wrote:

Anybody?
I can find plenty of examples on how to drag items from a view to a 
widget but can't find anything about dragging a custom item from one 
view to another.
Guess I will start to re-implement the entire drag, maybe the 
solution will become apparent then.



On 16/08/16 7:26 PM, Frank Rueter | OHUfx wrote:

Hi,

I am trying to get drag to work between two QListViews using a 
custom item.
I can't find the info I need online other than this document 
 which helped a 
little bit but now I'm stuck.


Drag from one QListView to another works fine when I use a 
QStandardItem to hold my data, but when I use a custom item I run 
into trouble, because the receiving model/view creates a 
QStandardItem when the incoming custom items are dropped.


Ideally I could tell the receiving model to use my custom item as 
the default item and otherwise just do it's thing, but I suppose it 
won't be that easy?!
I have played around with the receiving model's dropMimeData() and 
insertRows() methods but can't work out how to read the incoming 
data to then insert a custom item into the receiving model manually.
In QAbstractItemModel.dropMimeData() I tried reading 
mimeData.data('application/x-qabstractitemmodeldatalist'), but that 
returns a byte stream that I don't know how to handle.


Do I have to re-implement the sender's drag data as well to send the 
custom item in the first place?


It seems that everything works out of the box except the creation of 
the QStandardItem upon drop, rather than my custom item, so I am 
hoping I don't have to re-invent the (drag) wheel just to get 
that one part right?!


Any advise would be greatly appreciated.

Thanks,
frank



--
ohufxLogo 50x50  	*vfx compositing 
 | *workflow 
customisation and consulting 
* *




___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest




___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


--


Viktor Engelmann
Software Engineer

The Qt Company GmbH
Rudower Chaussee 13
D-12489 Berlin
viktor.engelm...@qt.io
+49 151 26784521
http://qt.io

Geschäftsführer: Mika Pälsi, Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht 
Charlottenburg, HRB 144331 B


 	 
 
 





___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QListView: drag custom item

2016-08-17 Thread Viktor Engelmann
The QStandardItem seems to be used to limit the drag to files,
images, text etc. so that you can drag & drop from and to external
applications (which is not possible for general objects).

http://doc.qt.io/qt-4.8/qstandarditem.html#subclassing says you should
subclass QStandardItem and override read and write or data and setData.
That is probably used to marshal and unmashal the objects, to make them
compatible to text, which can be passed to and from external applications.

Viktor


On 16.08.2016 23:56, Frank Rueter | OHUfx wrote:
> Anybody?
> I can find plenty of examples on how to drag items from a view to a
> widget but can't find anything about dragging a custom item from one
> view to another.
> Guess I will start to re-implement the entire drag, maybe the
> solution will become apparent then.
>
>
> On 16/08/16 7:26 PM, Frank Rueter | OHUfx wrote:
>> Hi,
>>
>> I am trying to get drag to work between two QListViews using a
>> custom item.
>> I can't find the info I need online other than this document
>>  which helped a
>> little bit but now I'm stuck.
>>
>> Drag from one QListView to another works fine when I use a
>> QStandardItem to hold my data, but when I use a custom item I run
>> into trouble, because the receiving model/view creates a
>> QStandardItem when the incoming custom items are dropped.
>>
>> Ideally I could tell the receiving model to use my custom item as the
>> default item and otherwise just do it's thing, but I suppose it won't
>> be that easy?!
>> I have played around with the receiving model's dropMimeData() and
>> insertRows() methods but can't work out how to read the incoming data
>> to then insert a custom item into the receiving model manually.
>> In QAbstractItemModel.dropMimeData() I tried reading
>> mimeData.data('application/x-qabstractitemmodeldatalist'), but that
>> returns a byte stream that I don't know how to handle.
>>
>> Do I have to re-implement the sender's drag data as well to send the
>> custom item in the first place?
>>
>> It seems that everything works out of the box except the creation of
>> the QStandardItem upon drop, rather than my custom item, so I am
>> hoping I don't have to re-invent the (drag) wheel just to get
>> that one part right?!
>>
>> Any advise would be greatly appreciated.
>>
>> Thanks,
>> frank
>>
>>
>>
>> -- 
>> ohufxLogo 50x50    *vfx compositing
>>  | *workflow
>> customisation and consulting
>> * *
>>
>>
>>
>> ___
>> Interest mailing list
>> Interest@qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>
>
>
> ___
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

-- 


Viktor Engelmann
Software Engineer

The Qt Company GmbH
Rudower Chaussee 13
D-12489 Berlin
viktor.engelm...@qt.io
+49 151 26784521
http://qt.io

Geschäftsführer: Mika Pälsi, Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht
Charlottenburg, HRB 144331 B






<>___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QListView: drag custom item

2016-08-16 Thread Frank Rueter | OHUfx

Anybody?
I can find plenty of examples on how to drag items from a view to a 
widget but can't find anything about dragging a custom item from one 
view to another.
Guess I will start to re-implement the entire drag, maybe the 
solution will become apparent then.



On 16/08/16 7:26 PM, Frank Rueter | OHUfx wrote:

Hi,

I am trying to get drag to work between two QListViews using a 
custom item.
I can't find the info I need online other than this document 
 which helped a 
little bit but now I'm stuck.


Drag from one QListView to another works fine when I use a 
QStandardItem to hold my data, but when I use a custom item I run into 
trouble, because the receiving model/view creates a QStandardItem when 
the incoming custom items are dropped.


Ideally I could tell the receiving model to use my custom item as the 
default item and otherwise just do it's thing, but I suppose it won't 
be that easy?!
I have played around with the receiving model's dropMimeData() and 
insertRows() methods but can't work out how to read the incoming data 
to then insert a custom item into the receiving model manually.
In QAbstractItemModel.dropMimeData() I tried reading 
mimeData.data('application/x-qabstractitemmodeldatalist'), but that 
returns a byte stream that I don't know how to handle.


Do I have to re-implement the sender's drag data as well to send the 
custom item in the first place?


It seems that everything works out of the box except the creation of 
the QStandardItem upon drop, rather than my custom item, so I am 
hoping I don't have to re-invent the (drag) wheel just to get 
that one part right?!


Any advise would be greatly appreciated.

Thanks,
frank



--
ohufxLogo 50x50  	*vfx compositing 
 | *workflow customisation 
and consulting * *




___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] QListView: drag custom item

2016-08-16 Thread Frank Rueter | OHUfx

Hi,

I am trying to get drag to work between two QListViews using a 
custom item.
I can't find the info I need online other than this document 
 which helped a 
little bit but now I'm stuck.


Drag from one QListView to another works fine when I use a 
QStandardItem to hold my data, but when I use a custom item I run into 
trouble, because the receiving model/view creates a QStandardItem when 
the incoming custom items are dropped.


Ideally I could tell the receiving model to use my custom item as the 
default item and otherwise just do it's thing, but I suppose it won't be 
that easy?!
I have played around with the receiving model's dropMimeData() and 
insertRows() methods but can't work out how to read the incoming data to 
then insert a custom item into the receiving model manually.
In QAbstractItemModel.dropMimeData() I tried reading 
mimeData.data('application/x-qabstractitemmodeldatalist'), but that 
returns a byte stream that I don't know how to handle.


Do I have to re-implement the sender's drag data as well to send the 
custom item in the first place?


It seems that everything works out of the box except the creation of the 
QStandardItem upon drop, rather than my custom item, so I am hoping I 
don't have to re-invent the (drag) wheel just to get that one part 
right?!


Any advise would be greatly appreciated.

Thanks,
frank



--
ohufxLogo 50x50  	*vfx compositing 
 | *workflow customisation 
and consulting * *


___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest