本文整理汇总了C++中qt::KeyboardModifiers::testFlag方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyboardModifiers::testFlag方法的具体用法?C++ KeyboardModifiers::testFlag怎么用?C++ KeyboardModifiers::testFlag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qt::KeyboardModifiers
的用法示例。
在下文中一共展示了KeyboardModifiers::testFlag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例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 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 );
}
示例4: 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);
}
示例5: 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());
}
示例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: 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 );
}
示例8: 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);
}
示例9: 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;
}
示例10: 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());
}
示例11: 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();
}
示例12: 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);
}
示例13: modifiersForDrag
static bool modifiersForDrag(Qt::KeyboardModifiers modifiers)
{
if (M_PREFS->getMouseSingleButton())
return modifiers.testFlag(Qt::ShiftModifier);
else
return true;
}
示例14: snapFactor
double snapFactor(Qt::KeyboardModifiers keyboardModifier)
{
if (keyboardModifier.testFlag(Qt::ControlModifier))
return 10.;
return 1.;
}
示例15: superKeyTapped
void
LauncherView::setHotkeysForModifiers(Qt::KeyboardModifiers modifiers)
{
/* This is the new new state of the Super key (AKA Meta key), while
m_superKeyPressed is the previous state of the key at the last modifiers change. */
bool superKeyPressed = modifiers.testFlag(Qt::MetaModifier);
if (m_superKeyPressed != superKeyPressed) {
m_superKeyPressed = superKeyPressed;
if (superKeyPressed) {
m_superPressIgnored = false;
/* If the key is pressed, start up a timer to monitor if it's being held short
enough to qualify as just a "tap" or as a proper hold */
m_superKeyHoldTimer.start();
} else {
m_superKeyHoldTimer.stop();
/* If the key is released, and was not being held, it means that the user just
performed a "tap". Unless we're told to ignore that tap, that is. */
if (!m_superKeyHeld && !m_superPressIgnored) {
Q_EMIT superKeyTapped();
}
/* Otherwise the user just terminated a hold. */
else if(m_superKeyHeld){
m_superKeyHeld = false;
Q_EMIT superKeyHeldChanged(m_superKeyHeld);
}
}
}
}