本文整理汇总了C++中QSplitter::count方法的典型用法代码示例。如果您正苦于以下问题:C++ QSplitter::count方法的具体用法?C++ QSplitter::count怎么用?C++ QSplitter::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSplitter
的用法示例。
在下文中一共展示了QSplitter::count方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: split
void SplitView::split(BufferView* view, Qt::Orientation orientation)
{
if (view) {
QSplitter* container = qobject_cast<QSplitter*>(view->parentWidget());
if (container) {
int index = container->indexOf(view);
BufferView* bv = 0;
const int size = (orientation == Qt::Horizontal ? container->width() : container->height()) - container->handleWidth();
if (container->count() == 1 || container->orientation() == orientation) {
container->setOrientation(orientation);
bv = createBufferView(container, index + 1);
QList<int> sizes;
for (int i = 0; i < container->count(); ++i)
sizes += size / container->count();
container->setSizes(sizes);
} else if (index != -1) {
QList<int> sizes = container->sizes();
QSplitter* splitter = wrap(view, orientation);
if (splitter) {
container->setSizes(sizes);
bv = createBufferView(splitter);
splitter->setSizes(QList<int>() << size/2 << size/2);
}
}
if (bv) {
bv->setBuffer(view->buffer());
emit viewAdded(bv);
}
}
}
}
示例2: viewSplitter
QSplitter* ScoreTab::viewSplitter(int n) const
{
TabScoreView* tsv = static_cast<TabScoreView*>(tab->tabData(n).value<void*>());
if (tsv == 0) {
// qDebug("ScoreTab::viewSplitter %d is zero", n);
return 0;
}
Score* score = tsv->score;
if (tsv->part) {
QList<Excerpt*>& excerpts = score->excerpts();
if (!excerpts.isEmpty() && ((tsv->part - 1) < excerpts.size()))
score = excerpts.at(tsv->part - 1)->partScore();
}
int nn = stack->count();
for (int i = 0; i < nn; ++i) {
QSplitter* sp = static_cast<QSplitter*>(stack->widget(i));
if (sp->count() == 0)
return 0;
ScoreView* v = static_cast<ScoreView*>(sp->widget(0));
if (v->score() == score)
return sp;
}
return 0;
}
示例3: eventFilter
bool eventFilter(QObject* obj, QEvent* event) override
{
// check input
if (event->type() != QEvent::MouseButtonDblClick)
return false;
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
if (mouseEvent->button() != Qt::LeftButton)
return false;
QSplitterHandle* splitterHandle = qobject_cast<QSplitterHandle*>(obj);
if (!splitterHandle)
return false;
QSplitter* splitter = splitterHandle->splitter();
if (!splitter || splitter->count() < 2)
return false;
// change splitter sizes to make description panel occupy ideal height
QWidget* bottomWidget = splitter->widget(1);
QList<int> sizes = splitter->sizes();
if (sizes.size() != 2)
return false;
sizes[0] += sizes[1];
sizes[1] = bottomWidget->heightForWidth(bottomWidget->size().width());
sizes[0] -= qMax(sizes[1], 0);
splitter->setSizes(sizes);
return true;
}
示例4: dropAreaAt
DockTabMotherWidget::TabWidgetArea DockTabMotherWidget::dropAreaAt(const QPoint &pos, Direction dir)
{
int countSplitter = _splitterLists[dir].size();
for (int indexSplitter = 0; indexSplitter < countSplitter; ++indexSplitter)
{
QSplitter *splitter = _splitterLists[dir].at(indexSplitter);
int countTabWidget = splitter->count();
for (int indexTabWidget = 0; indexTabWidget < countTabWidget; ++indexTabWidget)
{
InsertionDirection insertionDir;
if (getInsertionDirection(pos, splitter->widget(indexTabWidget), dir, insertionDir))
{
switch (insertionDir)
{
case NextSplitter:
return TabWidgetArea(dir, indexSplitter + 1, -1);
case PreviousSplitter:
return TabWidgetArea(dir, indexSplitter, -1);
case Next:
return TabWidgetArea(dir, indexSplitter, indexTabWidget + 1);
case Previous:
return TabWidgetArea(dir, indexSplitter, indexTabWidget);
default:
break;
}
}
}
}
return TabWidgetArea();
}
示例5: splitViewSpace
void KateViewManager::splitViewSpace( KateViewSpace* vs, // = 0
Qt::Orientation o )// = Qt::Horizontal
{
// emergency: fallback to activeViewSpace, and if still invalid, abort
if (!vs) vs = activeViewSpace();
if (!vs) return;
// get current splitter, and abort if null
QSplitter *currentSplitter = qobject_cast<QSplitter*>(vs->parentWidget());
if (!currentSplitter) return;
// index where to insert new splitter/viewspace
const int index = currentSplitter->indexOf( vs );
// create new viewspace
KateViewSpace* vsNew = new KateViewSpace( this );
// only 1 children -> we are the root container. So simply set the orientation
// and add the new view space, then correct the sizes to 50%:50%
if (currentSplitter->count() == 1)
{
if( currentSplitter->orientation() != o )
currentSplitter->setOrientation( o );
QList<int> sizes = currentSplitter->sizes();
sizes << (sizes.first() - currentSplitter->handleWidth() ) / 2;
sizes[0] = sizes[1];
currentSplitter->insertWidget( index, vsNew );
currentSplitter->setSizes( sizes );
}
else
{
// create a new QSplitter and replace vs with the splitter. vs and newVS are
// the new children of the new QSplitter
QSplitter* newContainer = new QSplitter( o );
newContainer->setOpaqueResize( KGlobalSettings::opaqueResize() );
QList<int> currentSizes = currentSplitter->sizes();
newContainer->addWidget( vs );
newContainer->addWidget( vsNew );
currentSplitter->insertWidget( index, newContainer );
newContainer->show();
// fix sizes of children of old and new splitter
currentSplitter->setSizes( currentSizes );
QList<int> newSizes = newContainer->sizes();
newSizes[0] = (newSizes[0] + newSizes[1] - newContainer->handleWidth()) / 2;
newSizes[1] = newSizes[0];
newContainer->setSizes( newSizes );
}
m_viewSpaceList.append( vsNew );
activeViewSpace()->setActive( false );
vsNew->setActive( true, true );
vsNew->show();
createView ((KTextEditor::Document*)activeView()->document());
updateViewSpaceActions ();
}
示例6:
QStackedWidget* SplitGrid2::getCellImp(int row, int col) const
{
if( col < 0 || col >= count() )
return 0;
QSplitter* s = static_cast<QSplitter*>( QSplitter::widget( col ) );
if( row < 0 || row >= s->count() )
return 0;
else
return static_cast<QStackedWidget*>( s->widget( row ) );
}
示例7: dropViewInsidePane
void ViewAreaImpl::dropViewInsidePane(ViewPane* pane, View* view, int dropEdge)
{
if(dropEdge == OVER){
addView(pane, view, true);
} else {
QSize destSize = pane->size();
QSplitter* parentSplitter = static_cast<QSplitter*>(pane->parentWidget());
if(parentSplitter->count() >= 2){
QList<int> sizes = parentSplitter->sizes();
QSplitter* newSplitter = new QSplitter(parentSplitter);
parentSplitter->insertWidget(parentSplitter->indexOf(pane), newSplitter);
newSplitter->addWidget(pane);
parentSplitter->setSizes(sizes);
parentSplitter = newSplitter;
}
ViewPane* newViewPane = new ViewPane(this, parentSplitter);
if(dropEdge == LEFT){
parentSplitter->setOrientation(Qt::Horizontal);
parentSplitter->insertWidget(0, newViewPane);
} else if(dropEdge == RIGHT){
parentSplitter->setOrientation(Qt::Horizontal);
parentSplitter->insertWidget(1, newViewPane);
} else if(dropEdge == TOP){
parentSplitter->setOrientation(Qt::Vertical);
parentSplitter->insertWidget(0, newViewPane);
} else {
parentSplitter->setOrientation(Qt::Vertical);
parentSplitter->insertWidget(1, newViewPane);
}
addView(newViewPane, view, true);
int half;
if(parentSplitter->orientation() == Qt::Horizontal){
half = destSize.height() / 2;
} else {
half = destSize.width() / 2;
}
QList<int> sizes;
sizes << half << half;
parentSplitter->setSizes(sizes);
}
}
示例8: parentSplitterOrView
EditorView *EditorView::findNextView()
{
SplitterOrView *current = parentSplitterOrView();
QTC_ASSERT(current, return this);
SplitterOrView *parent = current->findParentSplitter();
while (parent) {
QSplitter *splitter = parent->splitter();
QTC_ASSERT(splitter, return this);
QTC_ASSERT(splitter->count() == 2, return this);
// is current the first child? then the next view is the first one in current's sibling
if (splitter->widget(0) == current) {
SplitterOrView *second = qobject_cast<SplitterOrView *>(splitter->widget(1));
QTC_ASSERT(second, return this);
return second->findFirstView();
}
// otherwise go up the hierarchy
current = parent;
parent = current->findParentSplitter();
}
示例9: removeView
void MultiViewWidget::removeView()
{
ContainerWidget *container = qobject_cast<ContainerWidget *>(sender());
if (container) {
QSplitter *splitter = qobject_cast<QSplitter *>(container->parent());
if (splitter && splitter->count() == 2) {
// Get its parent, and insert the other widget into it, delete this widget.
QSplitter *splitterParent = qobject_cast<QSplitter *>(splitter->parent());
QWidget *moveWidget = splitter->widget(0);
if (moveWidget == container)
moveWidget = splitter->widget(1);
setActiveWidget(moveWidget);
if (splitterParent) {
int idx = splitterParent->indexOf(splitter);
splitterParent->insertWidget(idx, moveWidget);
splitter->deleteLater();
}
else if (splitter->parent() == this) {
// No more splits - back to single view widget.
QVBoxLayout *layoutParent = qobject_cast<QVBoxLayout *>(layout());
if (layoutParent) {
layoutParent->addWidget(moveWidget);
layoutParent->removeWidget(splitter);
splitter->deleteLater();
}
}
}
else if (container->parent() == this) {
// Delete the current container, and create the option container.
QVBoxLayout *vLayout = qobject_cast<QVBoxLayout *>(layout());
container->deleteLater();
ContainerWidget *newContainer = createContainer();
vLayout->addWidget(newContainer);
setActiveWidget(newContainer);
}
}
}
示例10: 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;
}
}
}
示例11: setCurrent
void ScoreTab::setCurrent(int n)
{
if (n == -1) {
clearTab2();
tab2->setVisible(false);
// clearTab2(); //??
emit currentScoreViewChanged(0);
return;
}
TabScoreView* tsv = static_cast<TabScoreView*>(tab->tabData(n).value<void*>());
QSplitter* vs = viewSplitter(n);
ScoreView* v;
if (!vs) {
vs = new QSplitter;
v = new ScoreView;
tab2->blockSignals(true);
tab2->setCurrentIndex(0);
tab2->blockSignals(false);
vs->addWidget(v);
v->setScore(scoreList->value(n));
stack->addWidget(vs);
}
else {
v = static_cast<ScoreView*>(vs->widget(0));
}
#ifdef OMR
if (v) {
Score* score = v->score();
if (score->showOmr() && score->omr()) {
if (vs->count() < 2) {
Omr* omr = score->omr();
OmrView* sv = omr->newOmrView(v);
v->setOmrView(sv);
vs->addWidget(sv);
connect(v, SIGNAL(scaleChanged(double)), sv, SLOT(setScale(double)));
connect(v, SIGNAL(offsetChanged(double,double)), sv, SLOT(setOffset(double,double)));
const QTransform _matrix = v->matrix();
double _spatium = score->spatium();
double scale = _matrix.m11() * _spatium;
sv->setScale(scale);
sv->setOffset(_matrix.dx(), _matrix.dy());
QList<int> sizes;
sizes << 100 << 100;
vs->setSizes(sizes);
}
}
else {
if (vs->count() > 1) {
QWidget* w = vs->widget(1);
delete w;
}
}
}
#endif
stack->setCurrentWidget(vs);
clearTab2();
if (v) {
Score* score = v->score();
if (score->parentScore())
score = score->parentScore();
QList<Excerpt*>& excerpts = score->excerpts();
if (!excerpts.isEmpty()) {
tab2->blockSignals(true);
tab2->addTab(score->name().replace("&","&&"));
foreach(const Excerpt* excerpt, excerpts) {
tab2->addTab(excerpt->partScore()->name().replace("&","&&"));
}
tab2->setCurrentIndex(tsv->part);
tab2->blockSignals(false);
tab2->setVisible(true);
}
示例12: 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();
}