qt中怎么设置QGraphicsScene *scene 的大小啊,不是QGraphicsView

qt中怎么设置QGraphicsScene *scene 的大小啊,不是QGraphicsView,第1张

可以使用setSceneRect()设置QGraphicsScene的大小。如果不设置,则默认为scene中包含所有子元素的边界区域( itemsBoundingRect()函数的返回值)。

详细的说明参看QGraphicsScene的文档,讲解很详细,看下面这段:

The scene's bounding rect is set by calling setSceneRect(). Items can be placed at any position on the scene, and the size of the scene is by default unlimited. The scene rect is used only for internal bookkeeping, maintaining the scene's item index. If the scene rect is unset, QGraphicsScene will use the bounding area of all items, as returned by itemsBoundingRect(), as the scene rect. However, itemsBoundingRect() is a relatively time consuming function, as it operates by collecting positional information for every item on the scene. Because of this, you should always set the scene rect when operating on large scenes.

QGraphicsSimpleTextItem provides a simple text label item

QGraphicsTextItem provides an advanced text browser item

这两个(反正第二个肯定可以的,第一个应该只是简单的lable),生成实例设置flag为Qt::TextEditorInteraction添加到screen就好了。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/tougao/11208557.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-14
下一篇 2023-05-14

发表评论

登录后才能评论

评论列表(0条)

保存