2014-12-05 4 views
1

내가 샘플 코드 쓰기 ::: 페인트()

class Element : public QQuickPaintedItem 
{ 
    void paint(QPainter *painter) 
    { 
     painter->setBrush(Qt::blue); 
     painter->drawRect(contentsBoundingRect()); 
    } 
} 

과 QML :

Element {  
    x : 19 
    y : 37 
    width : 371 
    height : 201 
} 

왼쪽 가장자리와 위쪽 가장자리가 잘됩니다하지만 오른쪽 가장자리와 하단 가장자리가 사라집니다!

실수를 저 지르지 않았습니까?

PS : 나는 WIN XP

답변

3

The bottom and right edge are drawn outside of the bounding rect에 QT5.3를 사용합니다. 여기

다음 코드를 사용할 때이 RECT 그리는 방법을 볼 수 있습니다

QPainter painter(this); 

painter.setPen(Qt::darkGreen); 
painter.drawRect(1, 2, 6, 4); 

당신은이 이상한 모양과 오른쪽에 차단 할 수 있지만, antialiased rectangle을 그리기 시도 할 수

및 아래 가장자리 및 오른쪽 가장자리에서 1을 뺄 수 있습니다.