本文整理汇总了C++中QWheelEvent::orientation方法的典型用法代码示例。如果您正苦于以下问题:C++ QWheelEvent::orientation方法的具体用法?C++ QWheelEvent::orientation怎么用?C++ QWheelEvent::orientation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWheelEvent
的用法示例。
在下文中一共展示了QWheelEvent::orientation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: event
/*!
\reimp
*/
bool QScrollBar::event(QEvent *event)
{
switch(event->type()) {
case QEvent::HoverEnter:
case QEvent::HoverLeave:
case QEvent::HoverMove:
if (const QHoverEvent *he = static_cast<const QHoverEvent *>(event))
d_func()->updateHoverControl(he->pos());
break;
#ifndef QT_NO_WHEELEVENT
case QEvent::Wheel: {
event->ignore();
// override wheel event without adding virtual function override
QWheelEvent *ev = static_cast<QWheelEvent *>(event);
int delta = ev->delta();
// scrollbar is a special case - in vertical mode it reaches minimum
// value in the upper position, however QSlider's minimum value is on
// the bottom. So we need to invert a value, but since the scrollbar is
// inverted by default, we need to inverse the delta value for the
// horizontal orientation.
if (ev->orientation() == Qt::Horizontal)
delta = -delta;
Q_D(QScrollBar);
if (d->scrollByDelta(ev->orientation(), ev->modifiers(), delta))
event->accept();
return true;
}
#endif
default:
break;
}
return QAbstractSlider::event(event);
}
示例2: eventFilter
bool MouseMagnifyingGlassInteractorComponent::eventFilter(QObject *, QEvent *e) {
bool updateMagnifyingGlass = false;
Coord screenCoords;
if (e->type() == QEvent::MouseMove) {
QMouseEvent *me = static_cast<QMouseEvent *>(e);
float x = glWidget->width() - me->x();
float y = me->y();
screenCoords = Coord(x, y, 0);
boxCenter = camera->viewportTo3DWorld(glWidget->screenToViewport(screenCoords));
updateMagnifyingGlass = true;
}
else if (e->type() == QEvent::Wheel) {
QWheelEvent *wheelEvent = (QWheelEvent *) e;
float x = glWidget->width() - wheelEvent->x();
float y = wheelEvent->y();
screenCoords = Coord(x, y, 0);
boxCenter = camera->viewportTo3DWorld(glWidget->screenToViewport(screenCoords));
int numDegrees = wheelEvent->delta() / 8;
int numSteps = numDegrees / 15;
if (wheelEvent->orientation() == Qt::Vertical && (wheelEvent->modifiers() == Qt::ControlModifier)) {
updateMagnifyingGlass = true;
radius += numSteps;
if (radius < 1) radius = 1;
delete fbo;
delete fbo2;
fbo = NULL;
fbo2 = NULL;
}
else if (wheelEvent->orientation() == Qt::Vertical && (wheelEvent->modifiers() == Qt::ShiftModifier)) {
updateMagnifyingGlass = true;
magnifyPower += numSteps;
if (magnifyPower < 1) magnifyPower = 1;
}
}
static bool canUseFbo = QGLFramebufferObject::hasOpenGLFramebufferObjects();
if (canUseFbo && updateMagnifyingGlass) {
generateMagnifyingGlassTexture(screenCoords);
drawInteractor = true;
glWidget->redraw();
return true;
}
return false;
}
示例3: eventFilter
bool FishEyeInteractorComponent::eventFilter(QObject *obj, QEvent *e) {
GlMainWidget *glWidget = (GlMainWidget*)obj;
Camera *camera=&glWidget->getScene()->getGraphCamera();
activateFishEye = false;
if (e->type() == QEvent::MouseMove ||
e->type() == QEvent::MouseButtonPress ||
e->type() == QEvent::MouseButtonRelease) {
activateFishEye = true;
QMouseEvent *me = (QMouseEvent *) e;
float x = glWidget->width() - me->x();
float y = me->y();
Coord screenCoords(x, y, 0);
fisheyeCenter = camera->viewportTo3DWorld(glWidget->screenToViewport(screenCoords));
glWidget->redraw();
return true;
}
else if (e->type() == QEvent::Wheel) {
activateFishEye = true;
QWheelEvent *wheelEvent = (QWheelEvent *) e;
int numDegrees = wheelEvent->delta() / 8;
int numSteps = numDegrees / 15;
if (wheelEvent->orientation() == Qt::Vertical && (wheelEvent->modifiers() == Qt::ControlModifier)) {
activateFishEye = true;
configWidget->setFishEyeRadius(configWidget->getFishEyeRadius() + configWidget->getFishEyeRadiusIncrementStep() * numSteps);
glWidget->redraw();
return true;
}
else if (wheelEvent->orientation() == Qt::Vertical && (wheelEvent->modifiers() == Qt::ShiftModifier)) {
activateFishEye = true;
float newHeight = configWidget->getFishEyeHeight() + configWidget->getFishEyeHeightIncrementStep() * numSteps;
if (newHeight < 0) {
newHeight = 0;
}
configWidget->setFishEyeHeight(newHeight);
glWidget->redraw();
return true;
}
return false;
}
return false;
}
示例4: applyWheel
// Применение изменений по вращении колеса мыши
void QWheelZoomSvc::applyWheel(QEvent *event,bool ax,bool ay)
{
// приводим тип QEvent к QWheelEvent
QWheelEvent *wEvent = static_cast<QWheelEvent *>(event);
// если вращается вертикальное колесо мыши
if (wEvent->orientation() == Qt::Vertical)
{
// определяем угол поворота колеса мыши
// (значение 120 соответствует углу поворота 15°)
int wd = wEvent->delta();
// вычисляем масштабирующий множитель
// (во сколько раз будет увеличен/уменьшен график)
double kw = sfact*wd/120;
if (wd != 0) // если колесо вращалось, то
{
// фиксируем исходные границы графика (если этого еще не было сделано)
zoom->fixBounds();
// получаем указатель на график
QwtPlot *plt = zoom->plot();
if (ax) // если задано масштабирование по горизонтали
{
// получаем карту основной горизонтальной шкалы
QwtScaleMap sm = plt->canvasMap(zoom->masterH());
// определяем центр отображаемого на шкале x интервала
double mx = (sm.s1()+sm.s2())/2;
// и полуширину интервала
double dx = (sm.s2()-sm.s1())/2;
// в зависимости от знака угла поворота колеса мыши
// уменьшаем полуширину отображаемых интервалов в kw раз
if (wd > 0) dx /= kw;
// или увеличиваем полуширину отображаемых интервалов в -kw раз
else dx *= -kw;
// устанавливаем новые левую и правую границы шкалы для оси x
// (центр изображаемой части графика остается на месте,
// а границы удаляются от центра, т.о. изображение графика уменьшается)
zoom->isb_x->set(mx-dx,mx+dx);
}
if (ay) // если задано масштабирование по вертикали
{
// получаем карту основной вертикальной шкалы
QwtScaleMap sm = plt->canvasMap(zoom->masterV());
// определяем центр отображаемого на шкале y интервала
double my = (sm.s1()+sm.s2())/2;
// и полуширину интервала
double dy = (sm.s2()-sm.s1())/2;
// в зависимости от знака угла поворота колеса мыши
// уменьшаем полуширину отображаемых интервалов в kw раз
if (wd > 0) dy /= kw;
// увеличиваем полуширину отображаемых интервалов в -kw раз
else dy *= -kw;
// устанавливаем новые нижнюю и верхнюю границы вертикальной шкалы
// (центр изображаемой части графика остается на месте,
// а границы удаляются от центра, т.о. изображение графика уменьшается)
zoom->isb_y->set(my-dy,my+dy);
}
// перестраиваем график (синхронно с остальными)
plt->replot();
}
}
}
示例5: event
bool QWheelArea::event(QEvent *e)
{
switch (e->type()) {
case QEvent::GraphicsSceneWheel: {
QGraphicsSceneWheelEvent *we = static_cast<QGraphicsSceneWheelEvent *>(e);
if (we->orientation() == Qt::Vertical)
setVerticalDelta(we->delta());
else
setHorizontalDelta(we->delta());
return true;
}
case QEvent::Wheel: {
QWheelEvent *we = static_cast<QWheelEvent *>(e);
if (we->orientation() == Qt::Vertical)
setVerticalDelta(we->delta());
else
setHorizontalDelta(we->delta());
return true;
}
default:
break;
}
return QDeclarativeItem::event(e);
}
示例6: eventFilter
bool OffscreenSurface::eventFilter(QObject* originalDestination, QEvent* event) {
if (!filterEnabled(originalDestination, event)) {
return false;
}
#ifdef DEBUG
// Don't intercept our own events, or we enter an infinite recursion
{
auto rootItem = _sharedObject->getRootItem();
auto quickWindow = _sharedObject->getWindow();
QObject* recurseTest = originalDestination;
while (recurseTest) {
Q_ASSERT(recurseTest != rootItem && recurseTest != quickWindow);
recurseTest = recurseTest->parent();
}
}
#endif
switch (event->type()) {
case QEvent::KeyPress:
case QEvent::KeyRelease: {
event->ignore();
if (QCoreApplication::sendEvent(_sharedObject->getWindow(), event)) {
return event->isAccepted();
}
break;
}
case QEvent::Wheel: {
QWheelEvent* wheelEvent = static_cast<QWheelEvent*>(event);
QPointF transformedPos = mapToVirtualScreen(wheelEvent->pos());
QWheelEvent mappedEvent(transformedPos, wheelEvent->delta(), wheelEvent->buttons(), wheelEvent->modifiers(),
wheelEvent->orientation());
mappedEvent.ignore();
if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &mappedEvent)) {
return mappedEvent.isAccepted();
}
break;
}
case QEvent::MouseMove: {
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
QPointF transformedPos = mapToVirtualScreen(mouseEvent->localPos());
QMouseEvent mappedEvent(mouseEvent->type(), transformedPos, mouseEvent->screenPos(), mouseEvent->button(),
mouseEvent->buttons(), mouseEvent->modifiers());
if (event->type() == QEvent::MouseMove) {
// TODO - this line necessary for the QML Tooltop to work (which is not currently being used), but it causes interface to crash on launch on a fresh install
// need to investigate into why this crash is happening.
//_qmlContext->setContextProperty("lastMousePosition", transformedPos);
}
mappedEvent.ignore();
if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &mappedEvent)) {
return mappedEvent.isAccepted();
}
break;
}
default:
break;
}
return false;
}
示例7: event
bool pHexEdit::QtHexEditScrollBar::event(QEvent* event) {
if(event->type() == QEvent::Wheel) {
QWheelEvent* wheelEvent = (QWheelEvent*)event;
if(wheelEvent->orientation() == Qt::Vertical) {
signed offset = wheelEvent->delta() < 0 ? +1 : -1;
self.scrollTo(sliderPosition() + offset);
return true;
}
}
return QScrollBar::event(event);
}
示例8: wheelEvent
void wheelEvent (State& state, const QWheelEvent& event) {
if (event.orientation () == Qt::Vertical) {
if (event.delta () > 0) {
state.camera ().stepAlongGaze (this->zoomInFactor);
}
else if (event.delta () < 0) {
state.camera ().stepAlongGaze (1.0f / this->zoomInFactor);
}
state.mainWindow ().mainWidget ().glWidget ().update ();
}
}
示例9: event
bool WebPage::event(QEvent *ev)
{
QMouseEvent* mouseEvent = NULL;
QWheelEvent* wheelEvent = NULL;
QKeyEvent* keyEvent = NULL;
QByteArray byteArray;
QBuffer buffer(&byteArray);
buffer.open(QIODevice::ReadWrite);
QDataStream out(&buffer);
out << (int) ev->type();
switch (ev->type()) {
case QEvent::MouseMove:
case QEvent::MouseButtonPress:
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonRelease:
if (OPNET::OpNetwork::instance()->isReplay() || OPNET::OpNetwork::instance()->isReplica())
return false;
mouseEvent = (static_cast<QMouseEvent*>(ev));
out << mouseEvent->pos() << mouseEvent->globalPos()
<< (int) mouseEvent->button() << (int) mouseEvent->buttons()
<< (int) mouseEvent->modifiers();
OPNET::OpNetwork::instance()->sendSysCall(MSG_LOG_USER_INPUT, (int) ev->type(), byteArray);
break;
case QEvent::Wheel:
if (OPNET::OpNetwork::instance()->isReplay() || OPNET::OpNetwork::instance()->isReplica())
return false;;
wheelEvent = (static_cast<QWheelEvent*>(ev));
out << wheelEvent->pos() << wheelEvent->globalPos()
<< wheelEvent->delta() << (int) wheelEvent->buttons()
<< (int) wheelEvent->modifiers() << (int) wheelEvent->orientation();
OPNET::OpNetwork::instance()->sendSysCall(MSG_LOG_USER_INPUT, (int) ev->type(), byteArray);
break;
case QEvent::KeyPress:
case QEvent::KeyRelease:
if (OPNET::OpNetwork::instance()->isReplay() || OPNET::OpNetwork::instance()->isReplica())
return false;
keyEvent = (static_cast<QKeyEvent*>(ev));
out << keyEvent->key() << (int) keyEvent->modifiers()
<< keyEvent->text() << keyEvent->isAutoRepeat()
<< (int) keyEvent->count();
OPNET::OpNetwork::instance()->sendSysCall(MSG_LOG_USER_INPUT, (int) ev->type(), byteArray);
break;
default:
break;
}
return QWebPage::event(ev);
}
示例10: runWheelEvent
ToolResponse runWheelEvent (const QWheelEvent& e) {
if (e.orientation () == Qt::Vertical && e.modifiers () == Qt::ShiftModifier) {
if (e.delta () > 0) {
this->radiusEdit.setIntValue ( this->radiusEdit.intValue ()
+ this->radiusEdit.intSingleStep () );
}
else if (e.delta () < 0) {
this->radiusEdit.setIntValue ( this->radiusEdit.intValue ()
- this->radiusEdit.intSingleStep () );
}
}
return ToolResponse::Redraw;
}
示例11: eventToString
QString KisTabletDebugger::eventToString(const QWheelEvent &ev, const QString &prefix)
{
QString string;
QTextStream s(&string);
dumpBaseParams(s, ev, prefix);
dumpMouseRelatedParams(s, ev);
s << "delta: " << ev.delta() << " ";
s << "orientation: " << (ev.orientation() == Qt::Horizontal ? "H" : "V") << " ";
return string;
}
示例12: eventFilter
virtual bool eventFilter( QObject *object, QEvent *event )
{
if ( event->type() == QEvent::Wheel )
{
QWheelEvent *we = ( QWheelEvent * )event;
QWheelEvent wheelEvent( QPoint( 5, 5 ), we->delta(),
we->buttons(), we->modifiers(),
we->orientation() );
QApplication::sendEvent( this, &wheelEvent );
return true;
}
return QwtWheel::eventFilter( object, event );
}
示例13: eventFilter
bool
ArtistInfoWidget::eventFilter( QObject* obj, QEvent* event )
{
if ( event->type() == QEvent::Wheel )
{
QWheelEvent* we = static_cast<QWheelEvent*>( event );
QWheelEvent* wheelEvent = new QWheelEvent(
we->pos(),
we->globalPos(),
we->delta(),
we->buttons(),
we->modifiers(),
we->orientation() );
qApp->postEvent( m_area->viewport(), wheelEvent );
event->accept();
return true;
}
else
return QObject::eventFilter( obj, event );
}
示例14: mouseWheelTimerFired
void WebView::mouseWheelTimerFired()
{
pMouseWheelTimer_->stop();
if (mouseWheelEvents_.empty())
return;
int totalDelta = 0;
for (int i = 0; i < mouseWheelEvents_.length(); i++)
{
totalDelta += mouseWheelEvents_.at(i).delta();
}
QWheelEvent event = mouseWheelEvents_.last();
mouseWheelEvents_.clear();
QWheelEvent totalEvent(event.pos(),
event.globalPos(),
totalDelta,
event.buttons(),
event.modifiers(),
event.orientation());
this->QWebView::wheelEvent(&totalEvent);
}
示例15: setDate
/* Checks for a focus out event. The display of the date is updated
* to display the proper date when the focus leaves.
*/
bool AnnotationDialog::KDateEdit::eventFilter(QObject *obj, QEvent *e)
{
if (obj == lineEdit()) {
if (e->type() == QEvent::Wheel) {
// Up and down arrow keys step the date
QWheelEvent* we = dynamic_cast<QWheelEvent*>(e);
Q_ASSERT( we != nullptr );
int step = 0;
step = we->delta() > 0 ? 1 : -1;
if (we->orientation() == Qt::Vertical) {
setDate( value.addDays(step) );
}
}
}
else {
// It's a date picker event
switch (e->type()) {
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonPress: {
QMouseEvent *me = (QMouseEvent*)e;
if (!mDateFrame->rect().contains(me->pos())) {
QPoint globalPos = mDateFrame->mapToGlobal(me->pos());
if (QApplication::widgetAt(globalPos) == this) {
// The date picker is being closed by a click on the
// KDateEdit widget. Avoid popping it up again immediately.
mDiscardNextMousePress = true;
}
}
break;
}
default:
break;
}
}
return false;
}