本文整理汇总了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);
}
示例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;
}
示例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));
}
示例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));
}