Results 1 to 4 of 4

Thread: QTextEdit - disable paste()

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QTextEdit - disable paste()

    There is a chance the following works.
    Qt Code:
    1. if(event->buttons().test(Qt::MidButton)) {
    2. return;
    3. }
    To copy to clipboard, switch view to plain text mode 

    Otherwise you can reimplement QTextEdit::insertFromMimeData like this
    Qt Code:
    1. class Edit : public QTextEdit
    2. {
    3. public:
    4. //the following effectively disables paste (as well as drop)
    5. void insertFromMimeData(const QMimeData *src) {}
    6. };
    To copy to clipboard, switch view to plain text mode 

    Edit:
    However note that the above will also disable text drop. You can tackle that by setting a flag in dragEnterEvent and checking the same in the reimplemented insertFromMimeData method.
    Do read the docs for clear picture.
    Last edited by Gopala Krishna; 31st January 2008 at 17:34.
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

Similar Threads

  1. Problem pasting text into a QTextEdit
    By Spockmeat in forum Qt Programming
    Replies: 8
    Last Post: 14th March 2009, 14:36
  2. QTextEdit slow to insert text
    By thomaspu in forum Qt Programming
    Replies: 4
    Last Post: 10th January 2008, 12:05
  3. Disable Return on QTextEdit
    By raphaelf in forum Newbie
    Replies: 3
    Last Post: 23rd May 2007, 08:04
  4. QTextEdit API questions (plain text)
    By Gaspar in forum Qt Programming
    Replies: 4
    Last Post: 16th May 2006, 06:03

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.