本文整理汇总了C++中QMainWindowLayout::moveToolBar方法的典型用法代码示例。如果您正苦于以下问题:C++ QMainWindowLayout::moveToolBar方法的具体用法?C++ QMainWindowLayout::moveToolBar怎么用?C++ QMainWindowLayout::moveToolBar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMainWindowLayout
的用法示例。
在下文中一共展示了QMainWindowLayout::moveToolBar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}