PDA

View Full Version : Question about drag & drop



franco.amato
31st August 2010, 20:54
Hi to all,
I need an help regarding a drag & drop mechanism.
I have a class inheriting from QDialog that implement a music trackList dialog ( that perform the drag ) and the mainwindow receive and process the drop. ( basically user select a music file and drag it over the mainwindow to be loaded).
Tracklist dialog is created with designer and there the drag is enambed ( I have a QListWidget containing the audio file list ).
What I would do is to be advised when the file has been correctly dropped and loaded in the mainwindow and delete it from the track list.

Thanx in advance.

Best Regards,
Franco

franco.amato
1st September 2010, 20:41
28 view and 0 reply, great!!

wysota
2nd September 2010, 03:43
What I would do is to be advised when the file has been correctly dropped and loaded in the mainwindow and delete it from the track list.
See return value of QDrag::exec().

franco.amato
2nd September 2010, 17:38
See return value of QDrag::exec().

Wysota thank you.
The problem is that the dialog implementing the drag is designed with Qt Designer and I can not see a call to QDrag::exec().
Should entirely rewrite manually the code instead of using Qt Designer?

Thank you.

Best Regards,
Franco

wysota
2nd September 2010, 18:03
I suggest you get yourself familiarized with drag & drop in itemviews if you are using it. If you don't want to do that then rewrite what you have to rewrite, I don't think Designer has anything to do with it, it is just a tool for laying out widgets. It's high time you started digging deeper into Qt code.

franco.amato
2nd September 2010, 18:13
I suggest you get yourself familiarized with drag & drop in itemviews if you are using it. If you don't want to do that then rewrite what you have to rewrite, I don't think Designer has anything to do with it, it is just a tool for laying out widgets. It's high time you started digging deeper into Qt code.

Wysota I agree with you, my problem is that the dialog implementing the drag is written by another person and he enabled drag feature in designer ( personally I don't know how ) and he gave to me the ui file. So I did a search for QDrag::exec and I didn't find anything.
Meanwhile thank you

squidge
2nd September 2010, 18:20
As Wysota has stated, once you have learnt how drag works manually, you will know exactly what you need to do. Qt designer isn't going to write the code for you.

franco.amato
2nd September 2010, 18:33
As Wysota has stated, once you have learnt how drag works manually, you will know exactly what you need to do. Qt designer isn't going to write the code for you.
Hi,
I don't want designer write the code for me, I only would know where add the code I have to add, nothing more

tbscope
2nd September 2010, 19:00
I assume you use Qt Creator here:
If you have created a designer widget with classes, you'll have a .cpp and a .h file (next to a .ui file) which you can use to add features.
Just click the header or source file to edit them and handle the drag and drop. You can install some event filters so you don't have to subclass your dialog or widget.

franco.amato
2nd September 2010, 21:09
I assume you use Qt Creator here:
If you have created a designer widget with classes, you'll have a .cpp and a .h file (next to a .ui file) which you can use to add features.
Just click the header or source file to edit them and handle the drag and drop. You can install some event filters so you don't have to subclass your dialog or widget.

Hi,
I'm not using Qt Creator. I'm using Visual Studio and Qt Designer for some dialogs.
As I said before the dialog implementing the drag was not designed by me, but by another developer. He gave to me the .ui, the .h and .cpp and I added them to the visual studio project. The dialog successfully implement the drag but there is no QDrag::exec in the code so I don't understand how it can work.
Can you clarify my doubts?
Regards,
Franco

wysota
2nd September 2010, 21:16
You have been given all the help you need. In doubt go to http://qt.gitorious.org, Qt's source code is there. I'm sure you can find a couple of QDrag::exec() calls there. Find the one relevant to your case and rewrite the virtual method that calls it adding the changes you require.