本文整理汇总了C++中DocumentView::setGeometry方法的典型用法代码示例。如果您正苦于以下问题:C++ DocumentView::setGeometry方法的具体用法?C++ DocumentView::setGeometry怎么用?C++ DocumentView::setGeometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocumentView
的用法示例。
在下文中一共展示了DocumentView::setGeometry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateLayout
void DocumentViewContainer::updateLayout()
{
// Stop update timer: this is useful if updateLayout() is called directly
// and not through scheduleLayoutUpdate()
d->mLayoutUpdateTimer->stop();
QList<DocumentView*> views = (d->mViews | d->mAddedViews).toList();
qSort(views.begin(), views.end(), viewLessThan);
bool animated = GwenviewConfig::animationMethod() != DocumentView::NoAnimation;
bool crossFade = d->mAddedViews.count() == 1 && d->mRemovedViews.count() == 1;
if (animated && crossFade) {
DocumentView* oldView = *d->mRemovedViews.begin();
DocumentView* newView = *d->mAddedViews.begin();
newView->setGeometry(rect());
newView->setEraseBorders(true);
QPropertyAnimation* anim = newView->fadeIn();
oldView->setZValue(-1);
connect(anim, SIGNAL(finished()), oldView, SLOT(hideAndDeleteLater()));
d->mRemovedViews.clear();
return;
}
if (!views.isEmpty()) {
// Compute column count
int colCount;
switch (views.count()) {
case 1:
colCount = 1;
break;
case 2:
colCount = 2;
break;
case 3:
colCount = 3;
break;
case 4:
colCount = 2;
break;
case 5:
colCount = 3;
break;
case 6:
colCount = 3;
break;
default:
colCount = 3;
break;
}
int rowCount = qCeil(views.count() / qreal(colCount));
Q_ASSERT(rowCount > 0);
int viewWidth = width() / colCount;
int viewHeight = height() / rowCount;
int col = 0;
int row = 0;
Q_FOREACH(DocumentView * view, views) {
QRect rect;
rect.setLeft(col * viewWidth);
rect.setTop(row * viewHeight);
rect.setWidth(viewWidth);
rect.setHeight(viewHeight);
if (animated) {
if (d->mViews.contains(view)) {
if (rect != view->geometry()) {
if (d->mAddedViews.isEmpty() && d->mRemovedViews.isEmpty()) {
// View moves because of a resize
view->moveTo(rect);
} else {
// View moves because the number of views changed,
// animate the change
view->moveToAnimated(rect);
}
}
} else {
view->setGeometry(rect);
view->fadeIn();
}
} else {
// Not animated, set final geometry and opacity now
view->setGeometry(rect);
view->setOpacity(1);
}
++col;
if (col == colCount) {
col = 0;
++row;
}
}