本文整理汇总了C++中QDockWidget::setParent方法的典型用法代码示例。如果您正苦于以下问题:C++ QDockWidget::setParent方法的具体用法?C++ QDockWidget::setParent怎么用?C++ QDockWidget::setParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDockWidget
的用法示例。
在下文中一共展示了QDockWidget::setParent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createDockWidget
QDockWidget* MainWindow::createDockWidget(KoDockFactoryBase* factory)
{
QDockWidget* dockWidget = 0;
if(!m_dockWidgetMap.contains(factory->id())) {
dockWidget = factory->createDockWidget();
// It is quite possible that a dock factory cannot create the dock; don't
// do anything in that case.
if(!dockWidget) return 0;
m_dockWidgets.push_back(dockWidget);
dockWidget->setObjectName(factory->id());
dockWidget->setParent(this);
if(dockWidget->widget() && dockWidget->widget()->layout())
dockWidget->widget()->layout()->setContentsMargins(1, 1, 1, 1);
Qt::DockWidgetArea side = Qt::RightDockWidgetArea;
bool visible = true;
switch(factory->defaultDockPosition()) {
case KoDockFactoryBase::DockTornOff:
dockWidget->setFloating(true); // position nicely?
break;
case KoDockFactoryBase::DockTop:
side = Qt::TopDockWidgetArea; break;
case KoDockFactoryBase::DockLeft:
side = Qt::LeftDockWidgetArea; break;
case KoDockFactoryBase::DockBottom:
side = Qt::BottomDockWidgetArea; break;
case KoDockFactoryBase::DockRight:
side = Qt::RightDockWidgetArea; break;
case KoDockFactoryBase::DockMinimized:
visible = false; break;
default:;
}
addDockWidget(side, dockWidget);
if(dockWidget->features() & QDockWidget::DockWidgetClosable) {
m_dockWidgetMenu->addAction(dockWidget->toggleViewAction());
if(!visible)
dockWidget->hide();
}
m_dockWidgetMap.insert(factory->id(), dockWidget);
} else {
dockWidget = m_dockWidgetMap[ factory->id()];
}
connect(dockWidget, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT(forceDockTabFonts()));
return dockWidget;
}
示例2: removeTab
void MainEditorPanel::removeTab( const TabLocation& location )
{
if ( location.m_internal )
{
m_tabsWidget->removeTab( location.m_index );
}
else
{
QWidget* parentWidget = m_undockedTabs[location.m_index]->parentWidget();
QDockWidget* parentDocker = static_cast< QDockWidget* >( parentWidget );
parentDocker->setParent( NULL );
parentDocker->deleteLater();
}
}
示例3: createDockWidget
QDockWidget* MainWindow::createDockWidget(KoDockFactoryBase* factory)
{
QDockWidget* dockWidget = 0;
if(!m_dockWidgetMap.contains(factory->id())) {
dockWidget = factory->createDockWidget();
// It is quite possible that a dock factory cannot create the dock; don't
// do anything in that case.
if(!dockWidget) return 0;
m_dockWidgets.push_back(dockWidget);
dockWidget->setObjectName(factory->id());
dockWidget->setParent(this);
if(dockWidget->widget() && dockWidget->widget()->layout())
dockWidget->widget()->layout()->setContentsMargins(1, 1, 1, 1);
Qt::DockWidgetArea side = Qt::RightDockWidgetArea;
bool visible = true;
switch(factory->defaultDockPosition()) {
case KoDockFactoryBase::DockTornOff:
dockWidget->setFloating(true); // position nicely?
break;
case KoDockFactoryBase::DockTop:
side = Qt::TopDockWidgetArea; break;
case KoDockFactoryBase::DockLeft:
side = Qt::LeftDockWidgetArea; break;
case KoDockFactoryBase::DockBottom:
side = Qt::BottomDockWidgetArea; break;
case KoDockFactoryBase::DockRight:
side = Qt::RightDockWidgetArea; break;
case KoDockFactoryBase::DockMinimized:
visible = false; break;
default:;
}
addDockWidget(side, dockWidget);
if(dockWidget->features() & QDockWidget::DockWidgetClosable) {
m_dockWidgetMenu->addAction(dockWidget->toggleViewAction());
if(!visible)
dockWidget->hide();
}
m_dockWidgetMap.insert(factory->id(), dockWidget);
} else {
dockWidget = m_dockWidgetMap[ factory->id()];
}
KConfigGroup group(KSharedConfig::openConfig(), "GUI");
QFont dockWidgetFont = QFontDatabase::systemFont(QFontDatabase::GeneralFont);
qreal pointSize = group.readEntry("palettefontsize", dockWidgetFont.pointSize() * 0.75);
pointSize = qMax(pointSize, QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont).pointSizeF());
dockWidgetFont.setPointSizeF(pointSize);
#ifdef Q_WS_MAC
dockWidget->setAttribute(Qt::WA_MacSmallSize, true);
#endif
dockWidget->setFont(dockWidgetFont);
connect(dockWidget, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)), this, SLOT(forceDockTabFonts()));
return dockWidget;
}