PDA

View Full Version : Prevent Select Text in QWebView



wirasto
9th November 2010, 05:22
How to prevent user select text in QWebView ? I use like this but I can't access the scrollbar



void mousePressEvent(QMouseEvent *) {}
void mouseReleaseEvent(QMouseEvent *) {}
void mouseDoubleClickEvent(QMouseEvent *) {}
void mouseMoveEvent(QMouseEvent *) {}

Thank's before

tbscope
9th November 2010, 05:38
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.

wirasto
9th November 2010, 05:56
OK. But how to clear text selected. I don't find a way in qtdoc

tbscope
9th November 2010, 06:02
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/messageviewer/mailwebview_webkit.cpp