Results 1 to 4 of 4

Thread: Prevent Select Text in QWebView

  1. #1
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question Prevent Select Text in QWebView

    How to prevent user select text in QWebView ? I use like this but I can't access the scrollbar


    Qt Code:
    1. void mousePressEvent(QMouseEvent *) {}
    2. void mouseReleaseEvent(QMouseEvent *) {}
    3. void mouseDoubleClickEvent(QMouseEvent *) {}
    4. void mouseMoveEvent(QMouseEvent *) {}
    To copy to clipboard, switch view to plain text mode 

    Thank's before

  2. #2
    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: Prevent Select Text in QWebView

    You can clear the selection of the text cursor whenever the selectionChanged signal occurs.

    Edit:
    Thats not ok.
    But you can try the QWebPage::MoveToNextChar action when the selectionChanged signal occurs. Hopefully that will move the cursor to the next character and clear the selection.
    Last edited by tbscope; 9th November 2010 at 05:57.

  3. #3
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: Prevent Select Text in QWebView

    OK. But how to clear text selected. I don't find a way in qtdoc

  4. #4
    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: Prevent Select Text in QWebView

    Make a feature request in the bugtracker, if one doesn't already exist.

    Here's another try:
    //This is an ugly hack to remove the selection, I found no other way to do it with QWebView
    QMouseEvent event(QEvent::MouseButtonPress, QPoint( 10, 10 ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier );
    QCoreApplication::sendEvent( page(), &event );
    QMouseEvent event2(QEvent::MouseButtonRelease, QPoint( 10, 10 ), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier );
    QCoreApplication::sendEvent( page(), &event2 );
    From: http://lxr.kde.org/source/KDE/kdepim...iew_webkit.cpp

Similar Threads

  1. Howto select/show a QWebElement in QWebview
    By nightghost in forum Qt Programming
    Replies: 1
    Last Post: 2nd September 2010, 12:51
  2. Replies: 4
    Last Post: 30th August 2010, 15:23
  3. Select text in QMessageBox
    By mpi in forum Qt Programming
    Replies: 0
    Last Post: 1st July 2010, 08:55
  4. How to select a line of text
    By benlyboy in forum Newbie
    Replies: 6
    Last Post: 25th April 2010, 23:56
  5. Auto text select in QTableWidgetItem
    By tstankey in forum Newbie
    Replies: 2
    Last Post: 5th October 2006, 20:40

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.