Results 1 to 8 of 8

Thread: Drag Drop Images from WebPage into QTextEdit

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Drag Drop Images from WebPage into QTextEdit

    subclass QTextEdit insertFromMimedata or so ...

    here a sample ....

    http://www.qt-apps.org/content/show....?content=80234


    Qt Code:
    1. void TextWriter::insertFromMime( const QMimeData * source )
    2. {
    3.  
    4. if ( source->formats().contains("application/x-picslists") ) {
    5. /* multiple image list */
    6. QByteArray dd = source->data("application/x-picslists");
    7. QList<SPics> li = OpenImageGroup(QString(dd));
    8. for (int i=0; i<li.size(); i++) {
    9. SPics conni = li[i];
    10. RegisterImage(conni,true);
    11. }
    12. return;
    13. }
    14. if ( source->hasImage() ) {
    15. QDateTime timer1( QDateTime::currentDateTime() );
    16. const QString TimestampsMs = QString("%1-%2-image").arg(timer1.toTime_t()).arg(timer1.toString("zzz"));
    17. QPixmap aspixmape = qvariant_cast<QPixmap>(source->imageData());
    18. if (!aspixmape.isNull()) {
    19. insertPixmap(aspixmape);
    20. }
    21. return;
    22. }
    23. /* external html */
    24.  
    25. if ( source->formats().contains("text/html") ) {
    26. QString draghtml = source->html();
    27. QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(draghtml);
    28. textCursor().insertFragment(fragment);
    29. return;
    30. }
    31. /* external plain text incomming */
    32. if ( source->hasText() ) {
    33. textCursor().insertText(source->text());
    34. return;
    35. }
    36. if ( source->hasUrls() ) {
    37. QList<QUrl> urls = source->urls();
    38. for ( int i = 0; i < urls.size(); ++i ) {
    39. QUrl gettyurl(urls.at(i));
    40. //////////// qDebug() << "### gettyurl " << gettyurl.toString();
    41. if (gettyurl.scheme() == "file") {
    42. ImageonCursor(gettyurl.toLocalFile());
    43. } else if (gettyurl.scheme() == "http") {
    44. Gloader *grephttp = new Gloader();
    45. grephttp->Setting(this,i,gettyurl);
    46. grephttp->start(QThread::LowPriority);
    47.  
    48. /* grep class Gloader on
    49.   http://fop-miniscribus.googlecode.com/svn/trunk/GraphicsViewEdit/include/mimedataeditor.h
    50.   */
    51.  
    52. }
    53.  
    54. }
    55.  
    56. return;
    57. }
    58.  
    59.  
    60. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to patrik08 for this useful post:

    fnmblot (20th May 2008)

Similar Threads

  1. Drag and Drop QTableWidget and QTableView
    By scorpion11 in forum Qt Programming
    Replies: 5
    Last Post: 8th April 2008, 09:33
  2. QTextEdit drag and drop
    By bunjee in forum Qt Programming
    Replies: 6
    Last Post: 7th February 2008, 16:41
  3. Problem with a cursor during Drag and Drop
    By mtrpoland in forum Qt Programming
    Replies: 1
    Last Post: 28th December 2007, 15:46
  4. Replies: 7
    Last Post: 8th September 2006, 16:19
  5. Drag and drop revisited
    By Big Duck in forum Newbie
    Replies: 2
    Last Post: 30th June 2006, 16:41

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
  •  
Qt is a trademark of The Qt Company.