本文整理汇总了C++中QAbstractScrollArea::installEventFilter方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractScrollArea::installEventFilter方法的具体用法?C++ QAbstractScrollArea::installEventFilter怎么用?C++ QAbstractScrollArea::installEventFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAbstractScrollArea
的用法示例。
在下文中一共展示了QAbstractScrollArea::installEventFilter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: activateOn
void FlickCharm::activateOn(QWidget *widget)
{
QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget);
if (scrollArea) {
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
QWidget *viewport = scrollArea->viewport();
viewport->installEventFilter(this);
scrollArea->installEventFilter(this);
d->flickData.remove(viewport);
d->flickData[viewport] = new FlickData;
d->flickData[viewport]->widget = widget;
d->flickData[viewport]->state = FlickData::Steady;
return;
}
QWebView *webView = qobject_cast<QWebView*>(widget);
if (webView) {
QWebFrame *frame = webView->page()->mainFrame();
frame->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
frame->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);
webView->installEventFilter(this);
d->flickData.remove(webView);
d->flickData[webView] = new FlickData;
d->flickData[webView]->widget = webView;
d->flickData[webView]->state = FlickData::Steady;
return;
}
qWarning() << "FlickCharm only works on QAbstractScrollArea (and derived classes)";
qWarning() << "or QWebView (and derived classes)";
}