本文整理汇总了C++中QDockWidget::isFloating方法的典型用法代码示例。如果您正苦于以下问题:C++ QDockWidget::isFloating方法的具体用法?C++ QDockWidget::isFloating怎么用?C++ QDockWidget::isFloating使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDockWidget
的用法示例。
在下文中一共展示了QDockWidget::isFloating方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: restoreStateOfFloating
void tst_QDockWidget::restoreStateOfFloating()
{
QMainWindow mw;
QDockWidget dock;
dock.setObjectName("dock1");
mw.addDockWidget(Qt::TopDockWidgetArea, &dock);
QVERIFY(!dock.isFloating());
QByteArray ba = mw.saveState();
dock.setFloating(true);
QVERIFY(dock.isFloating());
QVERIFY(mw.restoreState(ba));
QVERIFY(!dock.isFloating());
}
示例2: paintEvent
void KoDockWidgetTitleBar::paintEvent(QPaintEvent*)
{
QStylePainter p(this);
QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget());
int fw = q->isFloating() ? q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q) : 0;
int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q);
QStyleOptionDockWidgetV2 titleOpt;
titleOpt.initFrom(q);
QSize collapseButtonSize(0,0);
if (d->collapsable) {
collapseButtonSize = d->collapseButton->size();
}
QSize lockButtonSize(0,0);
if (d->lockable) {
lockButtonSize = d->lockButton->size();
}
titleOpt.rect = QRect(QPoint(fw + mw + collapseButtonSize.width() + lockButtonSize.width(), 0),
QSize(geometry().width() - (fw * 2) - mw - collapseButtonSize.width() - lockButtonSize.width(), geometry().height()));
titleOpt.title = q->windowTitle();
titleOpt.closable = hasFeature(q, QDockWidget::DockWidgetClosable);
titleOpt.floatable = hasFeature(q, QDockWidget::DockWidgetFloatable);
p.drawControl(QStyle::CE_DockWidgetTitle, titleOpt);
}
示例3: sender
void
Style::dockLocationChanged( Qt::DockWidgetArea /*area*/ )
{
QDockWidget *dock = carriedDock ? carriedDock : qobject_cast<QDockWidget*>( sender() );
if ( !dock )
return;
if ( dock->isFloating() || !Hacks::config.lockDocks )
{
if ( QWidget *title = dock->titleBarWidget() )
{
if ( title->objectName() == "bespin_docktitle_dummy" )
{
dock->setTitleBarWidget(0);
title->deleteLater();
}
else
title->show();
}
}
else
{
QWidget *title = dock->titleBarWidget();
if ( !title )
{
title = new QWidget;
title->setObjectName( "bespin_docktitle_dummy" );
dock->setTitleBarWidget( title );
}
if ( title->objectName() == "bespin_docktitle_dummy" )
dock->titleBarWidget()->hide();
}
}
示例4: lockDocks
void DockHost::lockDocks(bool lock)
{
if (lock == lastLock)
return;
lastLock = lock;
Q_FOREACH (QWidget* widget, widgets)
{
QDockWidget* dock = static_cast<QDockWidget*>(widget->parentWidget());
if (dock)
{
if (lock)
{
if (dock->isFloating())
{
dock->setFeatures(QDockWidget::DockWidgetFloatable);
dock->setAllowedAreas(Qt::NoDockWidgetArea);
}
else
{
dock->setFeatures(QDockWidget::NoDockWidgetFeatures);
dock->setAllowedAreas(Qt::AllDockWidgetAreas);
}
}
else
{
dock->setFeatures(QDockWidget::AllDockWidgetFeatures);
dock->setAllowedAreas(Qt::AllDockWidgetAreas);
}
adjustFloatingWindowFlags(dock);
}
}
示例5: settings
void MainWindow2::writeSettings()
{
QSettings settings("Pencil", "Pencil");
settings.setValue("editorPosition", pos());
settings.setValue("editorSize", size());
Palette* colourPalette = m_colorPalette;
if (colourPalette != NULL)
{
settings.setValue("colourPalettePosition", colourPalette->pos());
settings.setValue("colourPaletteSize", colourPalette->size());
settings.setValue("colourPaletteFloating", colourPalette->isFloating());
}
TimeLine* timelinePalette = editor->getTimeLine();
if (timelinePalette != NULL)
{
settings.setValue("timelinePalettePosition", timelinePalette->pos());
settings.setValue("timelinePaletteSize", timelinePalette->size());
settings.setValue("timelinePaletteFloating", timelinePalette->isFloating());
}
QDockWidget* toolWidget = editor->toolSet;
if (toolWidget != NULL)
{
settings.setValue("drawPalettePosition", toolWidget->pos());
settings.setValue("drawPaletteSize", toolWidget->size());
settings.setValue("drawPaletteFloating", toolWidget->isFloating());
}
QDockWidget* optionPalette = m_toolOptionWidget;
if (optionPalette != NULL)
{
settings.setValue("optionPalettePosition", optionPalette->pos());
settings.setValue("optionPaletteSize", optionPalette->size());
settings.setValue("optionPaletteFloating", optionPalette->isFloating());
}
QDockWidget* displayPalette = m_displayOptionWidget;
if (displayPalette != NULL)
{
settings.setValue("displayPalettePosition", displayPalette->pos());
settings.setValue("displayPaletteSize", displayPalette->size());
settings.setValue("displayPaletteFloating", displayPalette->isFloating());
}
}
示例6: minimumSize
QSize QDockWidgetLayout::minimumSize() const
{
QDockWidget *w = qobject_cast<QDockWidget*>(parentWidget());
QSize content(0, 0);
if (item_list[Content] != 0)
content = item_list[Content]->minimumSize();
return sizeFromContent(content, w->isFloating());
}
示例7: slotShowTitleBars
void HideTitleBars::slotShowTitleBars(bool show)
{
QList <QDockWidget *> docks = pCore->window()->findChildren<QDockWidget *>();
for (int i = 0; i < docks.count(); ++i) {
QDockWidget* dock = docks.at(i);
QWidget *bar = dock->titleBarWidget();
if (show) {
if (dock->isFloating()) {
if (bar) {
dock->setTitleBarWidget(0);
delete bar;
}
continue;
}
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
// Since Qt 5.6 we only display title bar in non tabbed dockwidgets
QList <QDockWidget*> docked = pCore->window()->tabifiedDockWidgets(dock);
if (docked.isEmpty()) {
if (bar) {
dock->setTitleBarWidget(0);
delete bar;
}
continue;
} else {
bool hasVisibleDockSibling = false;
foreach(QDockWidget *sub, docked) {
if (sub->toggleViewAction()->isChecked()) {
// we have another docked widget, so tabs are visible and can be used instead of title bars
hasVisibleDockSibling = true;
break;
}
}
if (!hasVisibleDockSibling) {
if (bar) {
dock->setTitleBarWidget(0);
delete bar;
}
continue;
}
}
if (!bar) {
dock->setTitleBarWidget(new QWidget);
}
#else
if (bar) {
dock->setTitleBarWidget(0);
delete bar;
}
#endif
} else {
if (!dock->isFloating() && !bar) {
dock->setTitleBarWidget(new QWidget);
}
}
}
示例8: ViewButtonClicked
void TitleWidget::ViewButtonClicked(void)
{
QDockWidget* Dock = qobject_cast<QDockWidget*>(parent());
if (Dock->isFloating())
{
if (Dock->geometry() == QApplication::desktop()->availableGeometry(Dock))
{
Dock->setGeometry(Dock->property("last-geometry").toRect());
}
else
{
Dock->setProperty("last-geometry", Dock->geometry());
Dock->setGeometry(QApplication::desktop()->availableGeometry(Dock));
}
}
else Dock->setFloating(true);
}
示例9: glRectF
void QStaticWidgetSwitchable3D::beforeOpen()
{
m_StaticImage = QPixmap(m_pWidget->size()/*, QImage::Format_RGB32*/);
if(!m_pWidget->isVisible())
{
m_pWidget->show();
m_pWidget->hide();
}
m_pWidget->render(&m_StaticImage);
m_pOwner->setFocus();
/*QGLWidget* qgl = NULL;
Q_FOREACH(qgl, m_QGLWidgetsToRender)
{
if(qgl->isVisible())
{
QWidget* parent = (QWidget*)m_pOwner;
QPoint screenQGLCoords = qgl->mapTo(m_pWidget, QPoint(0,0));
float w = float(qgl->width());
float h = float(qgl->height());
QRectF glRectF(0,0,w,h);
QPainter painter(&m_StaticImage);
painter.drawImage(glRectF, qgl->grabFrameBuffer(true));
}
}*/
if(m_pWidget->inherits("QMainWindow"))
{
QMainWindow* pMainWindow = (QMainWindow*)m_pWidget;
QList<QDockWidget*> docks = pMainWindow->findChildren<QDockWidget*>();
QDockWidget* dock = NULL;
Q_FOREACH(dock, docks)
{
if(dock->isFloating() && !dock->isHidden())
{
if(!m_FloatingVisibleDockWidgets.contains(dock))
{
m_FloatingVisibleDockWidgets.append(dock);
dock->setVisible(false);
}
}
}
}
示例10: drawBorder
void CommonWidget::drawBorder(const bool &pDockedTop, const bool &pDockedLeft,
const bool &pDockedBottom, const bool &pDockedRight,
const bool &pFloatingTop, const bool &pFloatingLeft,
const bool &pFloatingBottom, const bool &pFloatingRight)
{
// Draw a border around the widget
// Note: a qobject_cast is not good enough for mParent on OS X, so...
QDockWidget *dockWidget = dynamic_cast<QDockWidget *>(mParent);
QWidget *widget = dynamic_cast<QWidget *>(this);
if (dockWidget && widget) {
// The castings were successful, so our parent is really a QDockWidget,
// we are really a QWidget, and to top it all our parent is floating (or
// we want to force the drawing), so let's go ahead...
QPainter painter(widget);
QPen newPen = painter.pen();
newPen.setColor(borderColor());
painter.setPen(newPen);
bool isDocked = !dockWidget->isFloating();
QRect border = widget->rect();
if ((pDockedTop && isDocked) || (pFloatingTop && !isDocked))
painter.drawLine(border.topLeft(), border.topRight());
if ((pDockedLeft && isDocked) || (pFloatingLeft && !isDocked))
painter.drawLine(border.topLeft(), border.bottomLeft());
if ((pDockedBottom && isDocked) || (pFloatingBottom && !isDocked))
painter.drawLine(border.bottomLeft(), border.bottomRight());
if ((pDockedRight && isDocked) || (pFloatingRight && !isDocked))
painter.drawLine(border.topRight(), border.bottomRight());
}
}
示例11: setFloating
void tst_QDockWidget::setFloating()
{
const QRect deskRect = QApplication::desktop()->availableGeometry();
QMainWindow mw;
mw.move(deskRect.left() + deskRect.width() * 2 / 3, deskRect.top() + deskRect.height() / 3);
QDockWidget dw;
mw.addDockWidget(Qt::LeftDockWidgetArea, &dw);
mw.show();
QVERIFY(QTest::qWaitForWindowExposed(&mw));
QVERIFY(!dw.isFloating());
const QPoint dockedPosition = dw.mapToGlobal(dw.pos());
QSignalSpy spy(&dw, SIGNAL(topLevelChanged(bool)));
dw.setFloating(true);
const QPoint floatingPosition = dw.pos();
// QTBUG-31044, show approximately at old position, give or take window frame.
QVERIFY((dockedPosition - floatingPosition).manhattanLength() < 50);
QVERIFY(dw.isFloating());
QCOMPARE(spy.count(), 1);
QCOMPARE(spy.at(0).value(0).toBool(), dw.isFloating());
spy.clear();
dw.setFloating(dw.isFloating());
QCOMPARE(spy.count(), 0);
spy.clear();
dw.setFloating(false);
QVERIFY(!dw.isFloating());
QCOMPARE(spy.count(), 1);
QCOMPARE(spy.at(0).value(0).toBool(), dw.isFloating());
spy.clear();
dw.setFloating(dw.isFloating());
QCOMPARE(spy.count(), 0);
spy.clear();
}
示例12: setGeometry
void QDockWidgetLayout::setGeometry(const QRect &geometry)
{
QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget());
bool nativeDeco = nativeWindowDeco();
int fw = q->isFloating() && !nativeDeco
? q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q)
: 0;
if (nativeDeco) {
if (QLayoutItem *item = item_list[Content])
item->setGeometry(geometry);
} else {
int titleHeight = this->titleHeight();
if (verticalTitleBar) {
_titleArea = QRect(QPoint(fw, fw),
QSize(titleHeight, geometry.height() - (fw * 2)));
} else {
_titleArea = QRect(QPoint(fw, fw),
QSize(geometry.width() - (fw * 2), titleHeight));
}
if (QLayoutItem *item = item_list[TitleBar]) {
item->setGeometry(_titleArea);
} else {
QStyleOptionDockWidgetV2 opt;
q->initStyleOption(&opt);
if (QLayoutItem *item = item_list[CloseButton]) {
if (!item->isEmpty()) {
QRect r = q->style()
->subElementRect(QStyle::SE_DockWidgetCloseButton,
&opt, q);
if (!r.isNull())
item->setGeometry(r);
}
}
if (QLayoutItem *item = item_list[FloatButton]) {
if (!item->isEmpty()) {
QRect r = q->style()
->subElementRect(QStyle::SE_DockWidgetFloatButton,
&opt, q);
if (!r.isNull())
item->setGeometry(r);
}
}
}
if (QLayoutItem *item = item_list[Content]) {
QRect r = geometry;
if (verticalTitleBar) {
r.setLeft(_titleArea.right() + 1);
r.adjust(0, fw, -fw, -fw);
} else {
r.setTop(_titleArea.bottom() + 1);
r.adjust(fw, 0, -fw, -fw);
}
item->setGeometry(r);
}
}
}
示例13:
void KoDockWidgetTitleBar::Private::toggleFloating()
{
QDockWidget *q = qobject_cast<QDockWidget*>(thePublic->parentWidget());
q->setFloating(!q->isFloating());
}