本文整理汇总了C++中qt::KeyboardModifiers类的典型用法代码示例。如果您正苦于以下问题:C++ KeyboardModifiers类的具体用法?C++ KeyboardModifiers怎么用?C++ KeyboardModifiers使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KeyboardModifiers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyReleaseEvent
void SC_SimulateTab::keyReleaseEvent( QKeyEvent* e )
{
int k = e -> key();
Qt::KeyboardModifiers m = e -> modifiers();
switch ( k )
{
case Qt::Key_W:
{
if ( m.testFlag( Qt::ControlModifier ) == true )
{
TabCloseRequest( currentIndex() );
return;
}
}
break;
case Qt::Key_T:
{
if ( m.testFlag( Qt::ControlModifier ) == true )
{
insertNewTabAt( currentIndex() + 1 );
return;
}
}
break;
default: break;
}
SC_RecentlyClosedTab::keyReleaseEvent( e );
}
示例2: mousePressEvent
void MouseEventHandler::mousePressEvent( QMouseEvent* event )
{
if( event->button() == Qt::LeftButton )
{
Qt::KeyboardModifiers keyMod = event->modifiers();
bool shift = keyMod.testFlag(Qt::ShiftModifier);
bool ctrl = keyMod.testFlag(Qt::ControlModifier);
if( shift && !ctrl ) // as long as shift is pressed
{
Q_EMIT mouseLeftButtonShift( true, event->x(), event->y() );
}
if( ctrl && !shift ) // if only ctrl is pressed
{
Q_EMIT mouseLeftButtonCtrl( true, event->x(), event->y() );
}
if( !ctrl && !shift )
{
Q_EMIT mouseLeftButton( true, event->x(), event->y() );
}
}
else if( event->button() == Qt::RightButton )
{
Q_EMIT mouseRightButton( true, event->x(), event->y() );
}
}
示例3: keyPressEvent
void Wt_TextEdit::keyPressEvent(QKeyEvent *e)
{
printf("keyPressEvent key: %d \n", e->key());
printf("keyPressEvent text: %s \n", e->text().toStdString().c_str());
Qt::KeyboardModifiers keyMod = QApplication::keyboardModifiers();
bool isSHIFT = keyMod.testFlag(Qt::ShiftModifier);
bool isCTRL = keyMod.testFlag(Qt::ControlModifier);
if(e->key() == Qt::Key_Return) {
wt_pressEnter();
return;
}
if(e->text() == "}") {
QTextCursor textCursor = this->textCursor();
int currentPos = textCursor.position();
textCursor.insertText("}");
int findPositivePos = wt_findPairChar(currentPos, '{');
if(findPositivePos != -1) {
wt_indentChar(currentPos, findPositivePos);
}
return;
}
if(isCTRL && e->text() == "y"){
printf("key = ctrl + y\n");
redo();
return;
}
QPlainTextEdit::keyPressEvent(e);
}
示例4: QPointF
SoGesturePinchEvent::SoGesturePinchEvent(QPinchGesture* qpinch, QWidget *widget)
{
int h = widget->height();
QPointF widgetCorner = QPointF(widget->mapToGlobal(QPoint(0,0)));
qreal scaleToWidget = (widget->mapFromGlobal(QPoint(800,800))-widget->mapFromGlobal(QPoint(0,0))).x()/800.0;
QPointF pnt;//temporary
pnt = qpinch->startCenterPoint();
pnt = (pnt-widgetCorner)*scaleToWidget;//translate screen coord. into widget coord.
startCenter = SbVec2f(pnt.x(), h - pnt.y());
pnt = qpinch->centerPoint();
pnt = (pnt-widgetCorner)*scaleToWidget;
curCenter = SbVec2f(pnt.x(), h - pnt.y());
pnt = qpinch->lastCenterPoint();
pnt = (pnt-widgetCorner)*scaleToWidget;
deltaCenter = curCenter - SbVec2f(pnt.x(), h - pnt.y());
deltaZoom = qpinch->scaleFactor();
totalZoom = qpinch->totalScaleFactor();
deltaAngle = qpinch->rotationAngle();
totalAngle = qpinch->totalRotationAngle();
state = SbGestureState(qpinch->state());
this->setPosition(SbVec2s(curCenter));
Qt::KeyboardModifiers mods = QApplication::keyboardModifiers();
this->setAltDown(mods.testFlag(Qt::AltModifier));
this->setCtrlDown(mods.testFlag(Qt::ControlModifier));
this->setShiftDown(mods.testFlag(Qt::ShiftModifier));
this->setTime(SbTime::getTimeOfDay());
}
示例5: popupMenuModifiers
Qt::KeyboardModifiers KxPopupMenu::popupMenuModifiers() const
{
Qt::KeyboardModifiers mods = fModifiers;
// Swap the CTRL & ALT keys if requested on the fly.
//
if ( fsSwapMetaKeys ) {
bool isControl = mods.testFlag( Qt::ControlModifier );
bool isAlt = mods.testFlag( Qt::AltModifier );
if ( isControl ) {
mods &= ~Qt::ControlModifier;
}
if ( isAlt ) {
mods &= ~Qt::AltModifier;
}
if ( isControl ) {
mods |= Qt::AltModifier;
}
if ( isAlt ) {
mods |= Qt::ControlModifier;
}
}
return mods;
}
示例6: switch
SoGestureSwipeEvent::SoGestureSwipeEvent(QSwipeGesture *qwsipe, QWidget *widget)
{
angle = qwsipe->swipeAngle();
switch (qwsipe->verticalDirection()){
case QSwipeGesture::Up :
vertDir = +1;
break;
case QSwipeGesture::Down :
vertDir = -1;
break;
default:
vertDir = 0;
break;
}
switch (qwsipe->horizontalDirection()){
case QSwipeGesture::Right :
horzDir = +1;
break;
case QSwipeGesture::Left :
horzDir = -1;
break;
default:
horzDir = 0;
break;
}
state = SbGestureState(qwsipe->state());
Qt::KeyboardModifiers mods = QApplication::keyboardModifiers();
this->setAltDown(mods.testFlag(Qt::AltModifier));
this->setCtrlDown(mods.testFlag(Qt::ControlModifier));
this->setShiftDown(mods.testFlag(Qt::ShiftModifier));
this->setTime(SbTime::getTimeOfDay());
}
示例7: keyPressEvent
void SC_SimulateTab::keyPressEvent( QKeyEvent* e )
{
int k = e -> key();
Qt::KeyboardModifiers m = e -> modifiers();
if ( k == Qt::Key_Backtab ||
(k == Qt::Key_Tab && m.testFlag( Qt::ControlModifier ) && m.testFlag( Qt::ShiftModifier )) )
{
if ( wrapToEnd() )
return;
}
else if ( k == Qt::Key_Tab )
{
if ( wrapToBeginning() )
return;
}
else if ( k == Qt::Key_W && m.testFlag( Qt::ControlModifier ) )
{
// close the tab in keyReleaseEvent()
return;
}
else if ( k == Qt::Key_T && m.testFlag( Qt::ControlModifier ) )
{
return;
}
QTabWidget::keyPressEvent( e );
}
示例8: eventFilter
bool Scene_polyhedron_shortest_path_item::eventFilter(QObject* /*target*/, QEvent* event)
{
if(event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
Qt::KeyboardModifiers modifiers = keyEvent->modifiers();
m_shiftHeld = modifiers.testFlag(Qt::ShiftModifier);
}
if (event->type() == QEvent::MouseButtonPress && m_shiftHeld)
{
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
if(mouseEvent->button() == Qt::LeftButton)
{
Ray_3 mouseRay;
if (get_mouse_ray(mouseEvent, mouseRay))
{
if (run_point_select(mouseRay))
{
return true;
}
}
}
}
return false;
}
示例9: mouseDoubleClickEvent
void SkCanvasWidget::mouseDoubleClickEvent(QMouseEvent* event) {
Qt::KeyboardModifiers modifiers = event->modifiers();
if (modifiers.testFlag(Qt::ControlModifier)) {
snapWidgetTransform();
} else {
resetWidgetTransform();
}
}
示例10: modifiersForGreedyAdd
static bool modifiersForGreedyAdd(Qt::KeyboardModifiers modifiers)
{
// whether drag select should include intersected as well as contained features
if (M_PREFS->getMouseSingleButton())
return modifiers.testFlag(Qt::ShiftModifier) && modifiers.testFlag(Qt::AltModifier);
else
return modifiers.testFlag(Qt::ShiftModifier);
}
示例11: SbGestureState
SoGesturePanEvent::SoGesturePanEvent(QPanGesture* qpan, QWidget *widget)
{
totalOffset = SbVec2f(qpan->offset().x(), -qpan->offset().y());
deltaOffset = SbVec2f(qpan->delta().x(), -qpan->delta().y());
state = SbGestureState(qpan->state());
Qt::KeyboardModifiers mods = QApplication::keyboardModifiers();
this->setAltDown(mods.testFlag(Qt::AltModifier));
this->setCtrlDown(mods.testFlag(Qt::ControlModifier));
this->setShiftDown(mods.testFlag(Qt::ShiftModifier));
this->setTime(SbTime::getTimeOfDay());
}
示例12: manipulatedVector
QPointF manipulatedVector(const QPointF &vector, Qt::KeyboardModifiers keyboardModifier)
{
QPointF manipulatedVector = roundedVector(vector, snapFactor(keyboardModifier));
if (keyboardModifier.testFlag(Qt::ShiftModifier))
manipulatedVector.setX(0.);
if (keyboardModifier.testFlag(Qt::AltModifier))
manipulatedVector.setY(0.);
return manipulatedVector;
}
示例13: if
//handle mouse press events
//
void
SystemTopologyDrawing::mousePressEvent( QMouseEvent* event )
{
Qt::KeyboardModifiers mods = event->modifiers();
//check if shift is pressed
if ( mods.testFlag( Qt::ShiftModifier ) )
{
shiftPressed = true;
}
else
{
shiftPressed = false;
}
//check if control is pressed
if ( mods.testFlag( Qt::ControlModifier ) )
{
controlPressed = true;
}
else
{
controlPressed = false;
}
//get the position of the click
lastPoint = event->pos();
//for left-mouse-pull remember the first point to compute the
//difference later for mouse movement
if ( !leftMousePressed )
{
firstPoint = lastPoint;
}
//left button is handled at mouse release or mouse movement
if ( event->button() == Qt::LeftButton )
{
leftMousePressed = true;
event->accept();
}
else if ( event->button() == Qt::RightButton )
{
//right button is for context info (painted by draw())
rightMousePressed = true;
draw();
event->accept();
}
else
{
event->ignore();
}
data->updateSelection();
}
示例14: zoomRange
void
ScaleSliderQWidget::focusInEvent(QFocusEvent* e)
{
Qt::KeyboardModifiers mod = qApp->keyboardModifiers();
if ( mod.testFlag(Qt::ControlModifier) ) {
_imp->ctrlDown = true;
}
if ( mod.testFlag(Qt::ShiftModifier) ) {
_imp->shiftDown = true;
}
zoomRange();
QWidget::focusInEvent(e);
}
示例15: wheelEvent
void SkCanvasWidget::wheelEvent(QWheelEvent* event) {
Qt::KeyboardModifiers modifiers = event->modifiers();
if (modifiers.testFlag(Qt::ControlModifier)) {
zoom(event->delta() > 0 ? ZOOM_FACTOR : (1.0f / ZOOM_FACTOR), event->x(), event->y());
} else {
if (Qt::Horizontal == event->orientation()) {
fUserMatrix.postTranslate(event->delta(), 0.0f);
} else {
fUserMatrix.postTranslate(0.0f, event->delta());
}
fDebugger->setUserMatrix(fUserMatrix);
drawTo(fDebugger->index());
}
}