[英]Text Label inside Qt EllipseItem
Just started with Qt today and already got a problem. 今天才刚开始使用Qt,已经遇到了问题。 I want to place a text inside a
QGraphicsEllipseItem
but there seems to be no setText()
or setLabel()
function. 我想在
QGraphicsEllipseItem
内放置文本,但似乎没有setText()
或setLabel()
函数。 It should be just one word in the middle of the ellipse. 它应该只是椭圆中间的一个字。 The ellipse is movable, so the text should move aswell when the ellipse gets moved.
椭圆是可移动的,因此当椭圆移动时,文本也应同时移动。 Is there an easy way to do this?
是否有捷径可寻? Or do I have to create a separate text and update its position after moving the ellipse?
还是在移动椭圆后是否必须创建单独的文本并更新其位置? Hope there is an easier way.
希望有一个更简单的方法。
QGraphicsEllipseItem
is an element which you can place to a QGraphicsScene
. QGraphicsEllipseItem
是可以放置到QGraphicsScene
的元素。 There is also a QGraphicsTextItem
- an element for displaying text on a QGraphicsScene
. 还有一个
QGraphicsTextItem
用于在QGraphicsScene
上显示文本的元素。
So I think you should subclass QGraphicsEllipseItem
and add to it QGraphicsTextItem
to display your text. 因此,我认为您应该
QGraphicsEllipseItem
子类,并将其添加到QGraphicsTextItem
以显示您的文本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.