压力调节第一版
This commit is contained in:
+12
-14
@@ -427,22 +427,20 @@ void TestPrintWidget::openWorkFile(QString filePath){
|
||||
|
||||
// 将场景中所有项移动,使 pPicScene->itemsBoundingRect() 的左上角对齐到 scene 的 (0,0)
|
||||
// 计算当前边界并做平移(仅在有偏移时执行)
|
||||
{
|
||||
QRectF bounds = pPicScene->itemsBoundingRect();
|
||||
if (!bounds.isNull()) {
|
||||
qreal dx = -bounds.x();
|
||||
qreal dy = -bounds.y();
|
||||
if (!qFuzzyIsNull(dx) || !qFuzzyIsNull(dy)) {
|
||||
const auto items = pPicScene->items();
|
||||
for (QGraphicsItem* it : items) {
|
||||
// 仅移动属于场景根的项,避免重复移动子项
|
||||
if (!it) continue;
|
||||
QPointF oldPos = it->pos();
|
||||
it->setPos(oldPos + QPointF(dx, dy));
|
||||
}
|
||||
QRectF bounds = pPicScene->itemsBoundingRect();
|
||||
if (!bounds.isNull()) {
|
||||
qreal dx = -bounds.x();
|
||||
qreal dy = -bounds.y();
|
||||
if (!qFuzzyIsNull(dx) || !qFuzzyIsNull(dy)) {
|
||||
const auto items = pPicScene->items();
|
||||
for (QGraphicsItem* it : items) {
|
||||
// 仅移动属于场景根的项,避免重复移动子项
|
||||
if (!it) continue;
|
||||
QPointF oldPos = it->pos();
|
||||
it->setPos(oldPos + QPointF(dx, dy));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pViewer->centerOn(0, 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user