Results 1 to 8 of 8

Thread: Drag and Drop PDFs

  1. #1
    Join Date
    Jan 2006
    Posts
    75
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Drag and Drop PDFs

    First of all I'm using the open source edition for windows. (I hope it doesn't limit me from doing this...)

    I'm very uncertain about mime-types, but I would like to drag and drop a pdf from the desktop onto my application. Is this possible?

    My basic need is to have a section that when I drag and drop a pdf, it is automatically displayed in the section and it is also copied to a specific location. I could use a browse dialog, but dragging and dropping is much more convenient in the end.

  2. #2
    Join Date
    May 2006
    Posts
    28
    Thanks
    8
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Drag and Drop PDFs

    Qt should do what you want I think. Take a look at the qtdemo for drag and drop called drop site. I'm sure if you drag a pdf onto it you will see the mime type and data.

    Qt open source for windows should be just fine, same functionality as linux,mac...

    Do a search on this forum for drag and drop and you'll find many helpfull threads.

    For your section, you'll need to subclass something to implement functionality. For instance subclass the widget, and re-define some of these:

    virtual void dragEnterEvent ( QDragEnterEvent * event )
    virtual void dropEvent ( QDropEvent * event )

    You'll have to check that event->mimeData()->hasFormat("application/pdf");
    or something similiar. then accept the drop.
    I dont know anything about reading pdf's unfortunately.
    Good luck

  3. #3
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Drag and Drop PDFs

    Quote Originally Posted by Big Duck
    I dont know anything about reading pdf's unfortunately.
    There are bunch of soft dedicated to pdf reading; their sources should help :
    Xpdf source code
    Evince source code
    Current Qt projects : QCodeEdit, RotiDeCode

  4. #4
    Join Date
    Jan 2006
    Posts
    75
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Drag and Drop PDFs

    Thanks. I'll play around with it.

  5. #5
    Join Date
    Jan 2006
    Posts
    75
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Drag and Drop PDFs

    The drag and drop demo only returns a mime-type of text/uri-list regardless of what I drop into it.

    Any ideas/comments?

  6. #6
    Join Date
    Jan 2006
    Location
    Frankfurt, Germany
    Posts
    34
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Drag and Drop PDFs

    That's ok, look here:
    http://www.ip97.com/phpgtk/tutorials...d.urilist.html

    here (linux, kde) there's also a text/plain format included.

  7. The following user says thank you to kiker99 for this useful post:

    kroenecker (3rd July 2006)

  8. #7
    Join Date
    Jan 2006
    Posts
    75
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Drag and Drop PDFs

    I'm getting closer. I found that uri-list basically is a description of where the dropped file is located. When using mimetypes, the member function urls will return a qlist from which I can get the individual urls of all the files. I'm using QUrl::toLocalFile(). Then I can grab the file and do what I want with it.

  9. #8
    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: Drag and Drop PDFs

    If you drag a file from your desktop or file manager, you'll always get the uri-list mime, regardless of the file type. If you want to get the file as application/pdf, the application you drag from has to offer the file in pdf format (meaning that it has to be able to read and maybe also write pdf files) -- like pdf readers. For example my pdf viewer (Kpdf) doesn't support dragging, so it can't offer application/pdf.

  10. The following user says thank you to wysota for this useful post:

    kroenecker (6th July 2006)

Similar Threads

  1. Drag & drop with model/view (Qt4)
    By yogeshm02 in forum Qt Programming
    Replies: 16
    Last Post: 19th September 2011, 20:36
  2. Drag and drop outside the application
    By jpn in forum Newbie
    Replies: 7
    Last Post: 27th August 2006, 15:37
  3. Drag and drop revisited
    By Big Duck in forum Newbie
    Replies: 2
    Last Post: 30th June 2006, 16:41
  4. Drag & drop for QTreeView
    By yogeshm02 in forum Qt Programming
    Replies: 2
    Last Post: 30th January 2006, 14:32
  5. Drag 'n Drop problem
    By kiker99 in forum Qt Programming
    Replies: 4
    Last Post: 16th January 2006, 16:35

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.