Results 1 to 7 of 7

Thread: QTextEdit drag and drop

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Re: QTextEdit drag and drop

    Qt Code:
    1. //=============================================================================
    2. //=============================================================================
    3.  
    4. /* virtual */ void ZeParagraphWidget::enterEvent(QEvent * event)
    5. {
    6. if (mTextBrowser)
    7. {
    8. mTextBrowser->document()->deleteLater();
    9. mTextBrowser->deleteLater();
    10. mTextBrowser = NULL;
    11. }
    12.  
    13. mTextBrowser = new QTextBrowser(this);
    14. mTextBrowser->setDocument(mTextDocument->clone());
    15. mTextBrowser->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    16. mTextBrowser->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    17. mTextBrowser->setStyle(ZeStyle::get());
    18.  
    19. mTextBrowser->setOpenExternalLinks(true);
    20. mTextBrowser->setContextMenuPolicy(Qt::NoContextMenu);
    21.  
    22. mTextBrowser->move(-1, -1);
    23. mTextBrowser->resize(mTextDocument->idealWidth() + 2, height() + 2);
    24. mTextBrowser->show();
    25. update();
    26. }
    To copy to clipboard, switch view to plain text mode 

    That stuff is working. Instead of tweaking the QFrame I set my own style.
    Only problem is : when entered the newly created TextBrowser never gets deleted.

    I guess would need some kind of isActive() flag for the QTextBrowser in order to choose wether I can delete it or not in the leaveEvent.

    Thanks man.
    Last edited by bunjee; 7th February 2008 at 13:22.

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. Problem with a cursor during Drag and Drop
    By mtrpoland in forum Qt Programming
    Replies: 1
    Last Post: 28th December 2007, 15:46
  3. Strange behavior with Drag and Drop (not always drops)
    By Mona Shokrof in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2007, 18:00
  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.