Results 1 to 11 of 11

Thread: Question about drag & drop

  1. #1
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Question about drag & drop

    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

  2. #2
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Question about drag & drop

    28 view and 0 reply, great!!
    Franco Amato

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Question about drag & drop

    Quote Originally Posted by franco.amato View Post
    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().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Question about drag & drop

    Quote Originally Posted by wysota View Post
    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
    Last edited by franco.amato; 2nd September 2010 at 18:09. Reason: I did a mistake
    Franco Amato

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Question about drag & drop

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Question about drag & drop

    Quote Originally Posted by wysota View Post
    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
    Franco Amato

  7. #7
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Question about drag & drop

    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.

  8. #8
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Question about drag & drop

    Quote Originally Posted by fatjuicymole View Post
    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
    Franco Amato

  9. #9
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Question about drag & drop

    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.

  10. #10
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Question about drag & drop

    Quote Originally Posted by tbscope View Post
    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
    Franco Amato

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Question about drag & drop

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Drag and Drop General Question
    By onurozcelik in forum Qt Programming
    Replies: 0
    Last Post: 19th August 2010, 14:22
  2. Replies: 0
    Last Post: 1st July 2010, 06:16
  3. Replies: 0
    Last Post: 4th May 2010, 10:24
  4. drag-drop question
    By zgulser in forum Qt Programming
    Replies: 13
    Last Post: 6th July 2009, 14:56
  5. Drag n Drop question
    By Ashitaka in forum Qt Programming
    Replies: 1
    Last Post: 1st December 2006, 07:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.