当前位置: 首页>>代码示例>>C++>>正文


C++ QWindow::position方法代码示例

本文整理汇总了C++中QWindow::position方法的典型用法代码示例。如果您正苦于以下问题:C++ QWindow::position方法的具体用法?C++ QWindow::position怎么用?C++ QWindow::position使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QWindow的用法示例。


在下文中一共展示了QWindow::position方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: eventFilter

bool MouseEventFilter::eventFilter(QObject *obj, QEvent *event)
{
    if(event->type() == QEvent::MouseMove)
    {
        QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
        if(mouseEvent)
        {
            ApplicationManager::singleton()->setMouseX(mouseEvent->pos().x());
            ApplicationManager::singleton()->setMouseY(mouseEvent->pos().y());

            if(mouseEvent->buttons() && Qt::LeftButton && ApplicationManager::singleton()->grabbingWindowMoveHandle() &&
                    ApplicationManager::singleton()->windowControlButtonsEnabled())
            {
                QPoint diffPosition = mouseEvent->pos() - mousePos.toPoint();
                QPoint newPosition = ApplicationManager::singleton()->window()->position() + diffPosition;

                int oldWindowWidth = ApplicationManager::singleton()->window()->width();
                if(ApplicationManager::singleton()->showNormal())
                {
                    int windowWidth = ApplicationManager::singleton()->window()->width();
                    ApplicationManager::singleton()->window()->setPosition(newPosition.x() + (oldWindowWidth - windowWidth) * (mousePos.x() / oldWindowWidth), newPosition.y());
                    mousePos.setX(mousePos.x() - (oldWindowWidth - windowWidth) * (mousePos.x() / oldWindowWidth));
                }
                else
                {
                    ApplicationManager::singleton()->window()->setPosition(newPosition);
                }
            }
            else if(mouseEvent->buttons() && Qt::LeftButton && ApplicationManager::singleton()->grabbingWindowResizeHandle() &&
                    ApplicationManager::singleton()->windowControlButtonsEnabled())
            {
                QPoint diffPosition = mouseEvent->pos() - mousePos.toPoint();
                mousePos = mouseEvent->pos();

                QWindow *window = ApplicationManager::singleton()->window();
                int newWidth = window->width() + diffPosition.x();
                int newHeight = window->height() + diffPosition.y();

                if(newWidth < 1024) newWidth = 1024;
                if(newHeight < 600) newHeight = 600;

                window->setGeometry(window->position().x(), window->position().y(), newWidth, newHeight);
            }
        }
    }
    else if(event->type() == QEvent::MouseButtonPress)
    {
        QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
        if(mouseEvent)
        {
            mousePos = mouseEvent->pos();
        }
    }
    return QObject::eventFilter(obj, event);
}
开发者ID:andresilvasantos,项目名称:beatwhale,代码行数:55,代码来源:mouseeventfilter.cpp

示例2: mouseUp

 static void mouseUp(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint x, jint y)
 {
     QPoint globalPos(x,y);
     QWindow *tlw = m_mouseGrabber.data();
     if (!tlw)
         tlw = topLevelWindowAt(globalPos);
     QPoint localPos = tlw ? (globalPos -tlw->position()) : globalPos;
     QWindowSystemInterface::handleMouseEvent(tlw, localPos, globalPos
                                             , Qt::MouseButtons(Qt::NoButton));
     m_ignoreMouseEvents = false;
     m_mouseGrabber = 0;
 }
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:12,代码来源:androidjniinput.cpp

示例3: mouseDown

    static void mouseDown(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint x, jint y)
    {
        if (m_ignoreMouseEvents)
            return;

        QPoint globalPos(x,y);
        QWindow *tlw = topLevelWindowAt(globalPos);
        m_mouseGrabber = tlw;
        QPoint localPos = tlw ? (globalPos - tlw->position()) : globalPos;
        QWindowSystemInterface::handleMouseEvent(tlw,
                                                 localPos,
                                                 globalPos,
                                                 Qt::MouseButtons(Qt::LeftButton));
    }
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:14,代码来源:androidjniinput.cpp

示例4: longPress

    static void longPress(JNIEnv */*env*/, jobject /*thiz*/, jint /*winId*/, jint x, jint y)
    {
        //### TODO: add proper API for Qt 5.2
        static bool rightMouseFromLongPress = qgetenv("QT_NECESSITAS_COMPATIBILITY_LONG_PRESS").toInt();
        if (!rightMouseFromLongPress)
            return;
        m_ignoreMouseEvents = true;
        QPoint globalPos(x,y);
        QWindow *tlw = topLevelWindowAt(globalPos);
        QPoint localPos = tlw ? (globalPos-tlw->position()) : globalPos;

        // Release left button
        QWindowSystemInterface::handleMouseEvent(tlw,
                                                 localPos,
                                                 globalPos,
                                                 Qt::MouseButtons(Qt::NoButton));

        // Press right button
        QWindowSystemInterface::handleMouseEvent(tlw,
                                                 localPos,
                                                 globalPos,
                                                 Qt::MouseButtons(Qt::RightButton));
    }
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:23,代码来源:androidjniinput.cpp


注:本文中的QWindow::position方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。