本文整理汇总了C++中QMainWindowLayout类的典型用法代码示例。如果您正苦于以下问题:C++ QMainWindowLayout类的具体用法?C++ QMainWindowLayout怎么用?C++ QMainWindowLayout使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QMainWindowLayout类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Q_Q
void QToolBarPrivate::endDrag()
{
Q_Q(QToolBar);
Q_ASSERT(state != 0);
q->releaseMouse();
if (state->dragging) {
QMainWindowLayout *layout =
qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout());
Q_ASSERT(layout != 0);
if (!layout->plug(state->widgetItem)) {
if (q->isFloatable()) {
layout->restore();
#if defined(Q_WS_X11) || defined(Q_WS_MAC)
setWindowState(true); // gets rid of the X11BypassWindowManager window flag
// and activates the resizer
#endif
q->activateWindow();
} else {
layout->revert(state->widgetItem);
}
}
}
delete state;
state = 0;
}
示例2: Q_Q
void QDockWidgetPrivate::startDrag()
{
Q_Q(QDockWidget);
if (state == 0 || state->dragging)
return;
QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget()));
Q_ASSERT(layout != 0);
state->widgetItem = layout->unplug(q);
if (state->widgetItem == 0) {
/* I have a QMainWindow parent, but I was never inserted with
QMainWindow::addDockWidget, so the QMainWindowLayout has no
widget item for me. :( I have to create it myself, and then
delete it if I don't get dropped into a dock area. */
state->widgetItem = new QDockWidgetItem(q);
state->ownWidgetItem = true;
}
if (state->ctrlDrag)
layout->restore();
state->dragging = true;
}
示例3: Q_D
/*!
\internal
*/
void QToolBar::initStyleOption(QStyleOptionToolBar *option) const
{
Q_D(const QToolBar);
if (!option)
return;
option->initFrom(this);
if (orientation() == Qt::Horizontal)
option->state |= QStyle::State_Horizontal;
option->lineWidth = style()->pixelMetric(QStyle::PM_ToolBarFrameWidth, 0, this);
option->features = d->layout->movable()
? QStyleOptionToolBar::Movable
: QStyleOptionToolBar::None;
// if the tool bar is not in a QMainWindow, this will make the painting right
option->toolBarArea = Qt::NoToolBarArea;
// Add more styleoptions if the toolbar has been added to a mainwindow.
QMainWindow *mainWindow = qobject_cast<QMainWindow *>(parentWidget());
if (!mainWindow)
return;
QMainWindowLayout *layout = qobject_cast<QMainWindowLayout *>(mainWindow->layout());
Q_ASSERT_X(layout != 0, "QToolBar::initStyleOption()",
"QMainWindow->layout() != QMainWindowLayout");
layout->getStyleOptionInfo(option, const_cast<QToolBar *>(this));
}
示例4: Q_Q
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;
}
示例5: Q_Q
void QToolBarPrivate::startDrag(bool moving)
{
Q_Q(QToolBar);
Q_ASSERT(state != 0);
if ((moving && state->moving) || state->dragging)
return;
QMainWindow *win = qobject_cast<QMainWindow*>(parent);
Q_ASSERT(win != 0);
QMainWindowLayout *layout = qt_mainwindow_layout(win);
Q_ASSERT(layout != 0);
if (!moving) {
state->widgetItem = layout->unplug(q);
Q_ASSERT(state->widgetItem != 0);
}
state->dragging = !moving;
state->moving = moving;
}
示例6: Q_D
void QRasterWindowSurface::setGeometry(const QRect &rect)
{
QWindowSurface::setGeometry(rect);
Q_D(QRasterWindowSurface);
d->inSetGeometry = true;
if (d->image == 0 || d->image->width() < rect.width() || d->image->height() < rect.height()) {
#if (defined(Q_WS_X11) && !defined(QT_NO_XRENDER)) || (defined(Q_WS_WIN))
#ifndef Q_WS_WIN
if (d_ptr->translucentBackground)
#else
if (!qt_widget_private(window())->isOpaque)
#endif
prepareBuffer(QImage::Format_ARGB32_Premultiplied, window());
else
#endif
prepareBuffer(QNativeImage::systemFormat(), window());
}
d->inSetGeometry = false;
#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
QMainWindow* mWindow = qobject_cast<QMainWindow*>(window());
if (mWindow) {
QMainWindowLayout *mLayout = qobject_cast<QMainWindowLayout*>(mWindow->layout());
QList<QToolBar *> toolbarList = mLayout->qtoolbarsInUnifiedToolbarList;
for (int i = 0; i < toolbarList.size(); ++i) {
QToolBar* toolbar = toolbarList.at(i);
if (mLayout->toolBarArea(toolbar) == Qt::TopToolBarArea) {
QWidget* tbWidget = (QWidget*) toolbar;
if (tbWidget->d_func()->unifiedSurface) {
tbWidget->d_func()->unifiedSurface->setGeometry(rect);
}
}
}
}
#endif // Q_WS_MAC && QT_MAC_USE_COCOA
}
示例7: Q_D
/*! \reimp */
bool QDockWidget::event(QEvent *event)
{
Q_D(QDockWidget);
QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
QMainWindowLayout *layout = qt_mainwindow_layout(win);
switch (event->type()) {
#ifndef QT_NO_ACTION
case QEvent::Hide:
if (layout != 0)
layout->keepSize(this);
d->toggleViewAction->setChecked(false);
emit visibilityChanged(false);
break;
case QEvent::Show:
d->toggleViewAction->setChecked(true);
emit visibilityChanged(geometry().right() >= 0 && geometry().bottom() >= 0);
break;
#endif
case QEvent::ApplicationLayoutDirectionChange:
case QEvent::LayoutDirectionChange:
case QEvent::StyleChange:
case QEvent::ParentChange:
d->updateButtons();
break;
case QEvent::ZOrderChange: {
bool onTop = false;
if (win != 0) {
const QObjectList &siblings = win->children();
onTop = siblings.count() > 0 && siblings.last() == (QObject*)this;
}
if (!isFloating() && layout != 0 && onTop)
layout->raise(this);
break;
}
case QEvent::WindowActivate:
case QEvent::WindowDeactivate:
update(qobject_cast<QDockWidgetLayout *>(this->layout())->titleArea());
break;
case QEvent::ContextMenu:
if (d->state) {
event->accept();
return true;
}
break;
// return true after calling the handler since we don't want
// them to be passed onto the default handlers
case QEvent::MouseButtonPress:
if (d->mousePressEvent(static_cast<QMouseEvent *>(event)))
return true;
break;
case QEvent::MouseButtonDblClick:
if (d->mouseDoubleClickEvent(static_cast<QMouseEvent *>(event)))
return true;
break;
case QEvent::MouseMove:
if (d->mouseMoveEvent(static_cast<QMouseEvent *>(event)))
return true;
break;
#ifdef Q_OS_WIN
case QEvent::Leave:
if (d->state != 0 && d->state->dragging && !d->state->nca) {
// This is a workaround for loosing the mouse on Vista.
QPoint pos = QCursor::pos();
QMouseEvent fake(QEvent::MouseMove, mapFromGlobal(pos), pos, Qt::NoButton,
QApplication::mouseButtons(), QApplication::keyboardModifiers());
d->mouseMoveEvent(&fake);
}
break;
#endif
case QEvent::MouseButtonRelease:
if (d->mouseReleaseEvent(static_cast<QMouseEvent *>(event)))
return true;
break;
case QEvent::NonClientAreaMouseMove:
case QEvent::NonClientAreaMouseButtonPress:
case QEvent::NonClientAreaMouseButtonRelease:
case QEvent::NonClientAreaMouseButtonDblClick:
d->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(event));
return true;
case QEvent::Move:
d->moveEvent(static_cast<QMoveEvent*>(event));
break;
case QEvent::Resize:
// if the mainwindow is plugging us, we don't want to update undocked geometry
if (isFloating() && layout != 0 && layout->pluggingWidget != this)
d->undockedGeometry = geometry();
break;
default:
break;
}
return QWidget::event(event);
}
示例8: updateToolbarOffset
void QUnifiedToolbarSurface::updateToolbarOffset(QWidget *widget)
{
QMainWindowLayout *mlayout = qobject_cast<QMainWindowLayout*> (widget->window()->layout());
if (mlayout)
mlayout->updateUnifiedToolbarOffset();
}
示例9: Q_D
/*! \reimp */
bool QDockWidget::event(QEvent *event)
{
Q_D(QDockWidget);
QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
QMainWindowLayout *layout = qt_mainwindow_layout(win);
switch (event->type()) {
#ifndef QT_NO_ACTION
case QEvent::Hide:
if (layout != 0)
layout->keepSize(this);
d->toggleViewAction->setChecked(false);
emit visibilityChanged(false);
break;
case QEvent::Show: {
d->toggleViewAction->setChecked(true);
const QPoint parentTopLeft = isWindow() ?
QApplication::desktop()->availableGeometry(this).topLeft() : QPoint(0, 0);
emit visibilityChanged(geometry().right() >= parentTopLeft.x() && geometry().bottom() >= parentTopLeft.y());
}
break;
#endif
case QEvent::ApplicationLayoutDirectionChange:
case QEvent::LayoutDirectionChange:
case QEvent::StyleChange:
case QEvent::ParentChange:
d->updateButtons();
break;
case QEvent::ZOrderChange: {
bool onTop = false;
if (win != 0) {
const QObjectList &siblings = win->children();
onTop = siblings.count() > 0 && siblings.last() == (QObject*)this;
}
if (!isFloating() && layout != 0 && onTop)
layout->raise(this);
break;
}
case QEvent::WindowActivate:
case QEvent::WindowDeactivate:
update(qobject_cast<QDockWidgetLayout *>(this->layout())->titleArea());
break;
case QEvent::ContextMenu:
if (d->state) {
event->accept();
return true;
}
break;
// return true after calling the handler since we don't want
// them to be passed onto the default handlers
case QEvent::MouseButtonPress:
if (d->mousePressEvent(static_cast<QMouseEvent *>(event)))
return true;
break;
case QEvent::MouseButtonDblClick:
if (d->mouseDoubleClickEvent(static_cast<QMouseEvent *>(event)))
return true;
break;
case QEvent::MouseMove:
if (d->mouseMoveEvent(static_cast<QMouseEvent *>(event)))
return true;
break;
case QEvent::MouseButtonRelease:
if (d->mouseReleaseEvent(static_cast<QMouseEvent *>(event)))
return true;
break;
case QEvent::NonClientAreaMouseMove:
case QEvent::NonClientAreaMouseButtonPress:
case QEvent::NonClientAreaMouseButtonRelease:
case QEvent::NonClientAreaMouseButtonDblClick:
d->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(event));
return true;
case QEvent::Move:
d->moveEvent(static_cast<QMoveEvent*>(event));
break;
case QEvent::Resize:
// if the mainwindow is plugging us, we don't want to update undocked geometry
if (isFloating() && layout != 0 && layout->pluggingWidget != this)
d->undockedGeometry = geometry();
break;
default:
break;
}
return QWidget::event(event);
}