I have a QWebView which loads some webpage, but the problem when mouse is pressed and dragged it selectes everything which comes in its way.
Is there any way I can get rid of this?? I dont want t开发者_运维百科ext and other items to be selected.,
If I restrict mouseMove and mousePress then it other functionality with these event also gets restricted which is what I dont want.
I tried alot to find any way in QWebView/Qwebpage but doesnt find any, do i need to do something in webkit?
Please help
If you control the content that is being loaded, you can use css:
body { -webkit-user-select: none; }
Otherwise you might add a user stylesheet with this rule.
If you want a QT answer, maybe this is an option:
class MyWebView : public QWebView
{
protected:
virtual void mouseMoveEvent(QMouseEvent *) { /* dummy implementation */ }
public:
MyWebView(QWidget* parent) : QWebView(parent) { }
}
It overrides the original function and achieves that only press and release events are available in your webview. This worked for me on QT 4.8.
Try this method:
def mousePressEvent(self, event):
if event.pos().x() in range(self.frameRight - self.vScrollWidth+1,self.frameRight+1) or event.pos().y() in range(self.frameBottom+1 - self.hScrollHeight,self.frameBottom+1):
self.dragScroll = True
super(myWeb,self).mousePressEvent(event)
def mouseMoveEvent(self,event):
if self.dragScroll == True:
super(myWeb,self).mouseMoveEvent(event)
精彩评论