Qt 在场景/视图的中心添加项目
您好,
我正在尝试在当前屏幕的中心添加一个 QGraphicsItem。
我的QGraphicsScene非常大(10k X 10K),所以QGraphicsView无法完全显示它,有滚动条。
我找不到任何函数来返回当前屏幕的矩形,我在所有 QGraphicsScene 和 QGraphicsView 函数中进行了搜索。
有返回场景矩形的函数(它返回一个 10k X 10k 的矩形,但没有用),也有返回鼠标位置的函数,但我需要移动鼠标并单击菜单,这样鼠标将不再在里面场景和物品将在可见空间之外生成...
非常感谢。
Greetings,
I'm trying to add a QGraphicsItem exactly in the center of the current screen.
My QGraphicsScene is very large (10k X 10K), so the QGraphicsView cannot show it entirely, there are scroll bars.
I can't find any function to return me the rectangle of my current screen, i searched in all QGraphicsScene and QGraphicsView functions.
There are functions to return the scene rect (it returns a rect 10k X 10k but it's useless) and there are functions to return the mouse position, but i need to move my mouse and click on a menu so the mouse will no longer be inside the scene and the item will be generated outside the visible space...
Thank you very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该将视口的左上角 (0,0) 映射到场景。宽度&高度等于视口的矩形宽度和高度高度。
要获取当前屏幕的矩形,请尝试以下操作:
我假设您可以从这里处理它。
You should map your top left corner (0,0) of your viewport to the scene. Width & height are equal to the viewport's rect width & height.
To get the rectangle of the current screen try this,:
I assume you can handle it from here.