本文整理汇总了C++中QDockWidgetLayout类的典型用法代码示例。如果您正苦于以下问题:C++ QDockWidgetLayout类的具体用法?C++ QDockWidgetLayout怎么用?C++ QDockWidgetLayout使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QDockWidgetLayout类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Q_Q
void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca)
{
if (state != 0)
return;
Q_Q(QDockWidget);
QMainWindow *win = qobject_cast<QMainWindow*>(parent);
Q_ASSERT(win != 0);
QMainWindowLayout *layout = qt_mainwindow_layout(win);
Q_ASSERT(layout != 0);
if (layout->pluggingWidget != 0) // the main window is animating a docking operation
return;
state = new QDockWidgetPrivate::DragState;
state->dragging = false;
state->widgetItem = 0;
state->ownWidgetItem = false;
state->nca = nca;
state->ctrlDrag = false;
if (!q->isFloating()) {
// When dragging the widget out of the docking area,
// use the middle of title area as pressPos
QDockWidgetLayout *dwlayout = qobject_cast<QDockWidgetLayout*>(q->layout());
Q_ASSERT(dwlayout != 0);
int width = undockedGeometry.isNull() ? q->width() : undockedGeometry.width();
state->pressPos.setY(dwlayout->titleArea().height() / 2);
state->pressPos.setX(width / 2);
} else {
state->pressPos = pos;
}
}
示例2: Q_UNUSED
/*! \reimp */
void QDockWidget::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event)
QDockWidgetLayout *layout
= qobject_cast<QDockWidgetLayout*>(this->layout());
bool customTitleBar = layout->widgetForRole(QDockWidgetLayout::TitleBar) != 0;
bool nativeDeco = layout->nativeWindowDeco();
if (!nativeDeco && !customTitleBar) {
QStylePainter p(this);
// ### Add PixelMetric to change spacers, so style may show border
// when not floating.
if (isFloating()) {
QStyleOptionFrame framOpt;
framOpt.init(this);
p.drawPrimitive(QStyle::PE_FrameDockWidget, framOpt);
}
// Title must be painted after the frame, since the areas overlap, and
// the title may wish to extend out to all sides (eg. XP style)
QStyleOptionDockWidgetV2 titleOpt;
initStyleOption(&titleOpt);
p.drawControl(QStyle::CE_DockWidgetTitle, titleOpt);
}
}
示例3: Q_Q
void QDockWidgetPrivate::init()
{
Q_Q(QDockWidget);
QDockWidgetLayout *layout = new QDockWidgetLayout(q);
layout->setSizeConstraint(QLayout::SetMinAndMaxSize);
QAbstractButton *button = new QDockWidgetTitleButton(q);
button->setObjectName(QLatin1String("qt_dockwidget_floatbutton"));
QObject::connect(button, SIGNAL(clicked()), q, SLOT(_q_toggleTopLevel()));
layout->setWidgetForRole(QDockWidgetLayout::FloatButton, button);
button = new QDockWidgetTitleButton(q);
button->setObjectName(QLatin1String("qt_dockwidget_closebutton"));
QObject::connect(button, SIGNAL(clicked()), q, SLOT(close()));
layout->setWidgetForRole(QDockWidgetLayout::CloseButton, button);
resizer = new QWidgetResizeHandler(q);
resizer->setMovingEnabled(false);
resizer->setActive(false);
#ifndef QT_NO_ACTION
toggleViewAction = new QAction(q);
toggleViewAction->setCheckable(true);
fixedWindowTitle = qt_setWindowTitle_helperHelper(q->windowTitle(), q);
toggleViewAction->setText(fixedWindowTitle);
QObject::connect(toggleViewAction, SIGNAL(triggered(bool)),
q, SLOT(_q_toggleView(bool)));
#endif
updateButtons();
}
示例4: Q_D
/*! \reimp */
void QDockWidget::changeEvent(QEvent *event)
{
Q_D(QDockWidget);
QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout());
switch (event->type()) {
case QEvent::ModifiedChange:
case QEvent::WindowTitleChange:
update(layout->titleArea());
#ifndef QT_NO_ACTION
d->fixedWindowTitle = qt_setWindowTitle_helperHelper(windowTitle(), this);
d->toggleViewAction->setText(d->fixedWindowTitle);
#endif
#ifndef QT_NO_TABBAR
{
QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget());
if (QMainWindowLayout *winLayout = qt_mainwindow_layout(win)) {
if (QDockAreaLayoutInfo *info = winLayout->layoutState.dockAreaLayout.info(this))
info->updateTabBar();
}
}
#endif // QT_NO_TABBAR
break;
default:
break;
}
QWidget::changeEvent(event);
}
示例5: Q_D
void QDockWidget::setTitleBarWidget(QWidget *widget)
{
Q_D(QDockWidget);
QDockWidgetLayout *layout
= qobject_cast<QDockWidgetLayout*>(this->layout());
layout->setWidget(QDockWidgetLayout::TitleBar, widget);
d->updateButtons();
}
示例6: Q_Q
void QDockWidgetPrivate::unplug(const QRect &rect)
{
Q_Q(QDockWidget);
QRect r = rect;
r.moveTopLeft(q->mapToGlobal(QPoint(0, 0)));
#ifndef Q_WS_X11
QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(q->layout());
r.adjust(0, layout->titleHeight(), 0, 0);
#endif
setWindowState(true, true, r);
}
示例7: mouseDoubleClickEvent
bool QDockWidgetPrivate::mouseDoubleClickEvent(QMouseEvent *event)
{
QDockWidgetLayout *dwLayout = qobject_cast<QDockWidgetLayout*>(layout);
if (!dwLayout->nativeWindowDeco()) {
QRect titleArea = dwLayout->titleArea();
if (event->button() == Qt::LeftButton && titleArea.contains(event->pos()) &&
hasFeature(this, QDockWidget::DockWidgetFloatable)) {
_q_toggleTopLevel();
return true;
}
}
return false;
}
示例8: QVERIFY
void tst_QDockWidget::taskQTBUG_1665_closableChanged()
{
QDockWidget dock;
dock.show();
QVERIFY(QTest::qWaitForWindowExposed(&dock));
QDockWidgetLayout *l = qobject_cast<QDockWidgetLayout*>(dock.layout());
if (l && !l->nativeWindowDeco())
QSKIP("this machine doesn't support native dock widget");
QVERIFY(dock.windowFlags() & Qt::WindowCloseButtonHint);
//now let's remove the closable attribute
dock.setFeatures(dock.features() ^ QDockWidget::DockWidgetClosable);
QVERIFY(!(dock.windowFlags() & Qt::WindowCloseButtonHint));
}
示例9: isWindow
/*!
\property QDockWidget::floating
\brief whether the dock widget is floating
A floating dock widget is presented to the user as an independent
window "on top" of its parent QMainWindow, instead of being
docked in the QMainWindow.
\sa isWindow()
*/
void QDockWidget::setFloating(bool floating)
{
Q_D(QDockWidget);
// the initial click of a double-click may have started a drag...
if (d->state != 0)
d->endDrag(true);
QRect r = d->undockedGeometry;
if (floating && r.isNull()) {
QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout());
QRect titleArea = layout->titleArea();
int h = layout->verticalTitleBar ? titleArea.width() : titleArea.height();
QPoint p = mapToGlobal(QPoint(h, h));
r = QRect(p, size());
}
d->setWindowState(floating, false, floating ? r : QRect());
}
示例10: 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;
}
示例11: setWidget
/*!
Returns the widget for the dock widget. This function returns zero
if the widget has not been set.
\sa setWidget()
*/
QWidget *QDockWidget::widget() const
{
QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout());
return layout->widgetForRole(QDockWidgetLayout::Content);
}
示例12:
QWidget *QDockWidget::titleBarWidget() const
{
QDockWidgetLayout *layout
= qobject_cast<QDockWidgetLayout*>(this->layout());
return layout->widgetForRole(QDockWidgetLayout::TitleBar);
}
示例13: widget
/*!
Sets the widget for the dock widget to \a widget.
If the dock widget is visible when \a widget is added, you must
\l{QWidget::}{show()} it explicitly.
Note that you must add the layout of the \a widget before you call
this function; if not, the \a widget will not be visible.
\sa widget()
*/
void QDockWidget::setWidget(QWidget *widget)
{
QDockWidgetLayout *layout = qobject_cast<QDockWidgetLayout*>(this->layout());
layout->setWidgetForRole(QDockWidgetLayout::Content, widget);
}