CPU 사용량을 제공합니다 (drawRect, Hight Quality 앤티 앨리어싱 설정 등).setTransformOriginPoint 내가 정의 GraphicsItem 내 페인트 기능은 내가이 있었다 발견</p> <p>(최악의 경우) CPU의 100 %를 소요 발견
재미있는 점은 내가 제거하고 모든 것이 잘 작동한다는 것입니다. 나는 번역 후에 그것을 넣었으므로 아마도 새로운 변환 원점과 관련하여 회전 할 것입니다. 하지만 어쨌든 작동 ... 왜 궁금해 ...
하지만 주요 질문은 : 왜 100 %? 당신은 다른 모든 처리 작업에서 렌더링 분리해야
// Translate all to the center of the ruler calculated in the itemChange method.
painter->translate(rulerCenter_);
// rotate with the center where the ruler center is
//setTransformOriginPoint(rulerCenter_); <-- BRINGS 100% USAGE, NO SENSE WHY IT WORKS WITHOUT THIS.
painter->rotate(rulerRotation_);
// Set the color for the lines and quality of the lines
painter->setRenderHint(QPainter::Antialiasing, true);
painter->setPen(linesColor_);
// Draw long line of the ruler next to the wall
painter->drawLine(-length_/2,0,length_/2,0);
// Lines in the sides
painter->drawLine(-length_/2, 0, -length_/2, -sideLinesSize_);
painter->drawLine(length_/2, 0, length_/2, -sideLinesSize_);
// if we should flip the text for the user to read it properly...
if (flippedText_)
painter->rotate(180);
// Prepare for the text box, moving it to be centered
painter->translate(-textBox_.width()/2,-textBox_.height()/2);
// draw a box under the text so it hides whatever is under it
painter->setBrush(textBackgroundColor_);
painter->setPen(Qt::NoPen);
painter->drawRect(textBox_);
// Draw the text
painter->setPen(pen_);
painter->setFont(font_);
painter->setRenderHint(QPainter::HighQualityAntialiasing, true);
painter->drawText(textBox_, Qt::AlignCenter, meassureString_);
왜 페인트 함수에서'setTransformOriginPoint()'를 호출하겠습니까? – thuga