本文整理汇总了C++中qt::MouseButtons::testFlag方法的典型用法代码示例。如果您正苦于以下问题:C++ MouseButtons::testFlag方法的具体用法?C++ MouseButtons::testFlag怎么用?C++ MouseButtons::testFlag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qt::MouseButtons
的用法示例。
在下文中一共展示了MouseButtons::testFlag方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: containsDrawingButtons
bool MapEditorTool::containsDrawingButtons(Qt::MouseButtons buttons) const
{
if (buttons.testFlag(Qt::LeftButton))
return true;
return (draw_on_right_click && buttons.testFlag(Qt::RightButton) && editingInProgress());
}
示例2: testFlag
void tst_QFlags::testFlag() const
{
Qt::MouseButtons btn = Qt::LeftButton | Qt::RightButton;
QVERIFY(btn.testFlag(Qt::LeftButton));
QVERIFY(!btn.testFlag(Qt::MidButton));
btn = 0;
QVERIFY(!btn.testFlag(Qt::LeftButton));
}
示例3: requestToggleMaximization
void PreviewClient::requestToggleMaximization(Qt::MouseButtons buttons)
{
if (buttons.testFlag(Qt::LeftButton)) {
const bool set = !isMaximized();
setMaximizedHorizontally(set);
setMaximizedVertically(set);
} else if (buttons.testFlag(Qt::RightButton)) {
setMaximizedHorizontally(!isMaximizedHorizontally());
} else if (buttons.testFlag(Qt::MiddleButton)) {
setMaximizedVertically(!isMaximizedVertically());
}
}
示例4: getMouseButton
unsigned int EditorSceneWidget::getMouseButton(Qt::MouseButtons buttons,Qt::MouseButton button)
{
unsigned int flags = 0;
buttons |= button;
if(buttons.testFlag(Qt::LeftButton))
flags |= MOUSEB_LEFT;
if(buttons.testFlag(Qt::RightButton))
flags |= MOUSEB_RIGHT;
if(buttons.testFlag(Qt::MidButton))
flags |= MOUSEB_MIDDLE;
return flags;
}
示例5: mapButtons
MouseButton UsageLogger::mapButtons(Qt::MouseButtons b){
MouseButton button;
if(b.testFlag(Qt::LeftButton)){
button = LEFT;
}
else if(b.testFlag(Qt::RightButton)){
button = RIGHT;
}
else if(b.testFlag(Qt::MidButton)){
button = MIDDLE;
}
else{
button = NO;
}
return button;
}
示例6: buttonsToString
QString TabletWidget::buttonsToString(Qt::MouseButtons bs)
{
QStringList ret;
for (int i = 0; (uint)(1 << i) <= Qt::MaxMouseButton; ++i) {
Qt::MouseButton b = static_cast<Qt::MouseButton>(1 << i);
if (bs.testFlag(b))
ret << buttonToString(b);
}
return ret.join("|");
}
示例7: sensitivityLabelClicked
void QValueFilterEditor::sensitivityLabelClicked(Qt::MouseButtons buttons)
{
if (buttons.testFlag(Qt::LeftButton)){
if (m_sensitivity == Qt::CaseInsensitive){
setCaseSensitivity(Qt::CaseSensitive);
} else {
setCaseSensitivity(Qt::CaseInsensitive);
}
}
}
示例8: testFlagZeroFlag
void tst_QFlags::testFlagZeroFlag() const
{
{
Qt::MouseButtons btn = Qt::LeftButton | Qt::RightButton;
/* Qt::NoButton has the value 0. */
QVERIFY(!btn.testFlag(Qt::NoButton));
}
{
/* A zero enum set should test true with zero. */
QVERIFY(Qt::MouseButtons().testFlag(Qt::NoButton));
}
{
Qt::MouseButtons btn = Qt::NoButton;
QVERIFY(btn.testFlag(Qt::NoButton));
}
}
示例9: initializerLists
void tst_QFlags::initializerLists()
{
#if defined(Q_COMPILER_INITIALIZER_LISTS)
Qt::MouseButtons bts = { Qt::LeftButton, Qt::RightButton };
QVERIFY(bts.testFlag(Qt::LeftButton));
QVERIFY(bts.testFlag(Qt::RightButton));
QVERIFY(!bts.testFlag(Qt::MiddleButton));
#if defined(Q_COMPILER_CLASS_ENUM)
MyStrictNoOpFlags flags = { MyStrictNoOpEnum::StrictOne, MyStrictNoOpEnum::StrictFour };
QVERIFY(flags.testFlag(MyStrictNoOpEnum::StrictOne));
QVERIFY(flags.testFlag(MyStrictNoOpEnum::StrictFour));
QVERIFY(!flags.testFlag(MyStrictNoOpEnum::StrictTwo));
#endif // Q_COMPILER_CLASS_ENUM
#else
QSKIP("This test requires C++11 initializer_list support.");
#endif // Q_COMPILER_INITIALIZER_LISTS
}
示例10: mousePressEvent
// TODO consider using QWidget::mouseDoubleClickEvent() for double-click
void WzMainWindow::mousePressEvent(QMouseEvent *event)
{
mouseXPos = event->x();
mouseYPos = event->y();
Qt::MouseButtons presses = event->buttons(); // full state info for all buttons
MOUSE_KEY_CODE idx = buttonToIdx(event->button()); // index of button that caused event
if (idx == MOUSE_BAD)
{
debug(LOG_ERROR, "bad mouse idx"); // FIXME remove
return; // not recognized mouse button
}
MousePress mousePress;
mousePress.action = MousePress::Press;
mousePress.key = idx;
mousePress.pos = Vector2i(mouseXPos, mouseYPos);
mousePresses.push_back(mousePress);
aMouseState[idx].pressPos.x = mouseXPos;
aMouseState[idx].pressPos.y = mouseYPos;
if (aMouseState[idx].state == KEY_UP
|| aMouseState[idx].state == KEY_RELEASED
|| aMouseState[idx].state == KEY_PRESSRELEASE)
{
if (!presses.testFlag(Qt::MidButton)) //skip doubleclick check for wheel
{
// whether double click or not
if (realTime - aMouseState[idx].lastdown < DOUBLE_CLICK_INTERVAL)
{
aMouseState[idx].state = KEY_DOUBLECLICK;
aMouseState[idx].lastdown = 0;
}
else
{
aMouseState[idx].state = KEY_PRESSED;
aMouseState[idx].lastdown = realTime;
}
}
else //mouse wheel up/down was used, so notify. FIXME.
{
aMouseState[idx].state = KEY_PRESSED;
aMouseState[idx].lastdown = 0;
}
if (idx == MOUSE_LMB || idx == MOUSE_RMB || idx == MOUSE_MMB)
{
dragKey = idx;
dragX = mouseX();
dragY = mouseY();
}
}
}
示例11: matchFlagsLabelClicked
void QValueFilterEditor::matchFlagsLabelClicked(Qt::MouseButtons buttons)
{
if (buttons.testFlag(Qt::LeftButton)){
if (m_matchFlag == Qt::MatchStartsWith){
setMatchFlag(Qt::MatchEndsWith);
} else if (m_matchFlag == Qt::MatchEndsWith){
setMatchFlag(Qt::MatchContains);
} else if (m_matchFlag == Qt::MatchContains){
setMatchFlag(Qt::MatchStartsWith);
}
}
}
示例12: mouseReleaseEvent
//====================
// PROTECTED
//====================
void DirWidget::mouseReleaseEvent(QMouseEvent *ev){
static Qt::MouseButtons backmap = Qt::BackButton | Qt::ExtraButton5;
//qDebug() << "Mouse Click:" << ev->button();
if(backmap.testFlag(ev->button())){
ev->accept();
on_actionBack_triggered();
//}else if(ev->button()==Qt::ForwardButton()){
//ev->accept();
}else{
ev->ignore(); //not handled here
}
}
示例13: mouseDClick
void QInputGeneratorGeneric::mouseDClick(const QPoint& pos, Qt::MouseButtons state)
{
QTT_TRACE_FUNCTION();
const Qt::MouseButton buttons[] = {Qt::LeftButton, Qt::RightButton, Qt::MidButton, Qt::XButton1, Qt::XButton2};
QWidget *widget=QApplication::widgetAt(pos);
if (pos != currentPos) {
mouseEvent(MouseMove, widget, Qt::NoButton, currentButtons, 0, widget->mapFromGlobal(pos));
currentPos = pos;
}
for (unsigned int i=0; i<sizeof(buttons)/sizeof(Qt::MouseButton); i++) {
if (state.testFlag(buttons[i])) {
qttDebug() << "mouseClick" << pos << buttons[i];
mouseEvent(MouseDClick, widget, buttons[i], state, 0, widget->mapFromGlobal(pos));
}
}
}
示例14: sl_onItemEntered
void EditMarkerGroupDialog::sl_onItemEntered(const QModelIndex &idx) {
Qt::MouseButtons bs = QApplication::mouseButtons();
if (bs.testFlag(Qt::LeftButton)) {
sl_onItemSelected(idx);
}
}