本文整理汇总了C++中QSplitter::parentWidget方法的典型用法代码示例。如果您正苦于以下问题:C++ QSplitter::parentWidget方法的具体用法?C++ QSplitter::parentWidget怎么用?C++ QSplitter::parentWidget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSplitter
的用法示例。
在下文中一共展示了QSplitter::parentWidget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: closeTabWidgetFrame
void FrostEdit::closeTabWidgetFrame(TabWidgetFrame* tabWidFrame) {
QWidget* parent = tabWidFrame->parentWidget();
QSplitter* parentsplitter = qobject_cast<QSplitter*>(parent);
if(tabWidFrame->tabWidget() == mCurrentTabWidget) mCurrentTabWidget = nullptr;
if(parentsplitter != NULL) {
for(int i = 0; i < tabWidFrame->tabWidget()->count(); i++) {
closeTab(tabWidFrame->tabWidget(), i);
}
int index = mTabWidgetFrames.indexOf(tabWidFrame);
mTabWidgetFrames.first()->tabWidget()->setActive(true);
mTabWidgetFrames.remove(index);
delete tabWidFrame;
if(!parentsplitter->count() > 1) {
FrostEdit* edit = qobject_cast<FrostEdit*>(parentsplitter->parentWidget());
QSplitter* splitter = qobject_cast<QSplitter*>(parentsplitter->parentWidget());
TabWidgetFrame* wid = toTabWidgetFrame(parentsplitter->widget(0));
if(edit != nullptr && splitter == nullptr) {
edit->setCentralWidget(wid);
wid->setParent(edit);
} else if (splitter != nullptr && edit == nullptr) {
splitter->addWidget(wid);
wid->setParent(splitter);
}
delete parentsplitter;
}
}
}
示例2: removeViewSpace
void KateViewManager::removeViewSpace (KateViewSpace *viewspace)
{
// abort if viewspace is 0
if (!viewspace) return;
// abort if this is the last viewspace
if (m_viewSpaceList.count() < 2) return;
// get current splitter
QSplitter *currentSplitter = qobject_cast<QSplitter*>(viewspace->parentWidget());
// no splitter found, bah
if (!currentSplitter)
return;
// delete views of the viewspace
while (viewspace->viewCount() > 0 && viewspace->currentView())
{
deleteView( viewspace->currentView(), false );
}
// cu viewspace
m_viewSpaceList.removeAt( m_viewSpaceList.indexOf( viewspace ) );
delete viewspace;
// at this point, the splitter has exactly 1 child
Q_ASSERT( currentSplitter->count() == 1 );
// if we are not the root splitter, move the child one level up and delete
// the splitter then.
if (currentSplitter != this)
{
// get parent splitter
QSplitter *parentSplitter = qobject_cast<QSplitter*>(currentSplitter->parentWidget());
// only do magic if found ;)
if (parentSplitter)
{
int index = parentSplitter->indexOf (currentSplitter);
// save current splitter size, as the removal of currentSplitter looses the info
QList<int> parentSizes = parentSplitter->sizes();
parentSplitter->insertWidget (index, currentSplitter->widget (0));
if (qVersion() == QLatin1String("4.6.2")) currentSplitter->hide(); // bug in Qt v4.6.2, prevents crash (bug:232140), line can be removed once we are sure that noone uses Qt 4.6.2 anymore.
delete currentSplitter;
// now restore the sizes again
parentSplitter->setSizes(parentSizes);
}
}
else if( QSplitter* splitter = qobject_cast<QSplitter*>(currentSplitter->widget(0)) )
{
// we are the root splitter and have only one child, which is also a splitter
// -> eliminate the redundant splitter and move both children into the root splitter
QList<int> sizes = splitter->sizes();
// adapt splitter orientation to the splitter we are about to delete
currentSplitter->setOrientation(splitter->orientation());
currentSplitter->addWidget( splitter->widget(0) );
currentSplitter->addWidget( splitter->widget(0) );
delete splitter;
currentSplitter->setSizes( sizes );
}
// find the view that is now active.
KTextEditor::View* v = activeViewSpace()->currentView();
if ( v )
activateView( v );
updateViewSpaceActions ();
emit viewChanged();
}