本文整理汇总了C++中QAbstractScrollArea::parent方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractScrollArea::parent方法的具体用法?C++ QAbstractScrollArea::parent怎么用?C++ QAbstractScrollArea::parent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAbstractScrollArea
的用法示例。
在下文中一共展示了QAbstractScrollArea::parent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
bool eventFilter(QObject *o, QEvent *e) {
switch (e->type()) {
case QEvent::MouseMove: {
if (notRelevant(e))
return false;
if (m_panning) {
const QPoint pos = static_cast<QMouseEvent*>(e)->pos();
bool noClick = !m_click;
if (noClick) {
const int dx = pos.x() - m_lastPos.x();
const int dy = pos.y() - m_lastPos.y();
if (QAbstractScrollArea *area = qobject_cast<QAbstractScrollArea*>(o->parent())) {
// dolphin stacks a graphicsview into a view inside a view ...
QAbstractScrollArea *runner = area;
while ((runner = qobject_cast<QAbstractScrollArea*>(runner->parent())))
area = runner;
if (dx && area->horizontalScrollBar())
area->horizontalScrollBar()->setValue(area->horizontalScrollBar()->value() - dx);
if (dy && area->verticalScrollBar()) {
area->verticalScrollBar()->setValue(area->verticalScrollBar()->value() - dy);
}
} else { // mostly QWebView
int factor[2] = {1, 1};
if (o->inherits("QWebView")) {
foreach (const QObject *o2, o->children()) {
if (o2->inherits("QWebPage")) {
foreach (const QObject *o3, o2->children()) {
if (o3->inherits("QWebFrame")) {
const QSize sz = o3->property("contentsSize").toSize();
if (sz.isValid()) {
const QSize wsz = static_cast<QWidget*>(o)->size();
factor[0] = qMin(6, qRound(float(sz.width()) / wsz.width()));
factor[1] = qMin(6, qRound(float(sz.height()) / wsz.height()));
}
break;
}
}
break;
}
}
}
if (dy) {
QWheelEvent wev(pos, dy*factor[1], Qt::NoButton, Qt::NoModifier, Qt::Vertical);
QApplication::sendEvent(o, &wev);
}
if (dx) {
QWheelEvent weh(pos, dx*factor[0], Qt::NoButton, Qt::NoModifier, Qt::Horizontal);
QApplication::sendEvent(o, &weh); // "oi wehh"
}
}
}
m_lastPos = pos;
// qDebug() << "mouse move" << m_click << QPoint(m_startPoint - m_lastPos) << QApplication::startDragDistance();
m_click = m_click && qAbs(QPoint(m_startPoint - m_lastPos).manhattanLength()) < QApplication::startDragDistance();
// qDebug() << "->" << m_click;
return true; // noClick;
}
return false;
}