本文整理汇总了C++中QMainWindowLayout::hover方法的典型用法代码示例。如果您正苦于以下问题:C++ QMainWindowLayout::hover方法的具体用法?C++ QMainWindowLayout::hover怎么用?C++ QMainWindowLayout::hover使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMainWindowLayout
的用法示例。
在下文中一共展示了QMainWindowLayout::hover方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: moveEvent
void QDockWidgetPrivate::moveEvent(QMoveEvent *event)
{
Q_Q(QDockWidget);
if (state == 0 || !state->dragging || !state->nca || !q->isWindow())
return;
// When the native window frame is being dragged, all we get is these mouse
// move events.
if (state->ctrlDrag)
return;
QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
Q_ASSERT(layout != 0);
QPoint globalMousePos = event->pos() + state->pressPos;
layout->hover(state->widgetItem, globalMousePos);
}
示例2: mouseMoveEvent
bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event)
{
bool ret = false;
#if !defined(QT_NO_MAINWINDOW)
Q_Q(QDockWidget);
if (!state)
return ret;
QDockWidgetLayout *dwlayout
= qobject_cast<QDockWidgetLayout*>(layout);
QMainWindowLayout *mwlayout
= qobject_cast<QMainWindowLayout*>(q->parentWidget()->layout());
if (!dwlayout->nativeWindowDeco()) {
if (!state->dragging
&& mwlayout->pluggingWidget == 0
&& (event->pos() - state->pressPos).manhattanLength()
> QApplication::startDragDistance()) {
startDrag();
#ifdef Q_OS_WIN
grabMouseWhileInWindow();
#else
q->grabMouse();
#endif
ret = true;
}
}
if (state->dragging && !state->nca) {
QPoint pos = event->globalPos() - state->pressPos;
q->move(pos);
if (!state->ctrlDrag)
mwlayout->hover(state->widgetItem, event->globalPos());
ret = true;
}
#endif // !defined(QT_NO_MAINWINDOW)
return ret;
}
示例3: nonClientAreaMouseEvent
void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
{
Q_Q(QDockWidget);
int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q);
QRect geo = q->geometry();
QRect titleRect = q->frameGeometry();
#ifdef Q_WS_MAC
if ((features & QDockWidget::DockWidgetVerticalTitleBar)) {
titleRect.setTop(geo.top());
titleRect.setBottom(geo.bottom());
titleRect.setRight(geo.left() - 1);
} else
#endif
{
titleRect.setLeft(geo.left());
titleRect.setRight(geo.right());
titleRect.setBottom(geo.top() - 1);
titleRect.adjust(0, fw, 0, 0);
}
switch (event->type()) {
case QEvent::NonClientAreaMouseButtonPress:
if (!titleRect.contains(event->globalPos()))
break;
if (state != 0)
break;
if (qobject_cast<QMainWindow*>(parent) == 0)
break;
if (isAnimating())
break;
initDrag(event->pos(), true);
if (state == 0)
break;
#ifdef Q_WS_WIN
// On Windows, NCA mouse events don't contain modifier info
state->ctrlDrag = GetKeyState(VK_CONTROL) & 0x8000;
#else
state->ctrlDrag = event->modifiers() & Qt::ControlModifier;
#endif
startDrag();
break;
case QEvent::NonClientAreaMouseMove:
if (state == 0 || !state->dragging)
break;
if (state->nca) {
endDrag();
}
#ifdef Q_OS_MAC
else { // workaround for lack of mouse-grab on Mac
QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
Q_ASSERT(layout != 0);
q->move(event->globalPos() - state->pressPos);
if (!state->ctrlDrag)
layout->hover(state->widgetItem, event->globalPos());
}
#endif
break;
case QEvent::NonClientAreaMouseButtonRelease:
#ifdef Q_OS_MAC
if (state)
endDrag();
#endif
break;
case QEvent::NonClientAreaMouseButtonDblClick:
_q_toggleTopLevel();
break;
default:
break;
}
}
示例4: mouseMoveEvent
bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event)
{
Q_Q(QToolBar);
if (!state) {
#ifdef Q_WS_MAC
if (!macWindowDragging)
return false;
QWidget *w = q->window();
const QPoint delta = event->pos() - macWindowDragPressPosition;
w->move(w->pos() + delta);
return true;
#endif
return false;
}
QMainWindow *win = qobject_cast<QMainWindow*>(parent);
if (win == 0)
return true;
QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(win->layout());
Q_ASSERT(layout != 0);
if (layout->pluggingWidget == 0
&& (event->pos() - state->pressPos).manhattanLength() > QApplication::startDragDistance()) {
const bool wasDragging = state->dragging;
const bool moving = !q->isWindow() && (orientation == Qt::Vertical ?
event->x() >= 0 && event->x() < q->width() :
event->y() >= 0 && event->y() < q->height());
startDrag(moving);
if (!moving && !wasDragging) {
#ifdef Q_OS_WIN
grabMouseWhileInWindow();
#else
q->grabMouse();
#endif
}
}
if (state->dragging) {
QPoint pos = event->globalPos();
// if we are right-to-left, we move so as to keep the right edge the same distance
// from the mouse
if (q->isLeftToRight())
pos -= state->pressPos;
else
pos += QPoint(state->pressPos.x() - q->width(), -state->pressPos.y());
q->move(pos);
layout->hover(state->widgetItem, event->globalPos());
} else if (state->moving) {
const QPoint rtl(q->width() - state->pressPos.x(), state->pressPos.y()); //for RTL
const QPoint globalPressPos = q->mapToGlobal(q->isRightToLeft() ? rtl : state->pressPos);
int pos = 0;
QPoint delta = event->globalPos() - globalPressPos;
if (orientation == Qt::Vertical) {
pos = q->y() + delta.y();
} else {
if (q->isRightToLeft()) {
pos = win->width() - q->width() - q->x() - delta.x();
} else {
pos = q->x() + delta.x();
}
}
layout->moveToolBar(q, pos);
}
return true;
}