setSceneRect
2016-07-23 19:39
831 查看
sceneRect : QRectF
This property holds the scene rectangle; the bounding rectangle of the scene.
这个函数限定了场景边框。
The scene rectangle defines the extent of the scene. It is primarily used by QGraphicsView to
determine the view's default scrollable area, and by
QGraphicsScene to manage item indexing.
extent 长度
scrollable area 可滑动区间
index 参数
If unset, or if set to a null QRectF,
sceneRect() will return the largest bounding rect of all items on the scene since the scene was created (i.e., a rectangle that grows when items are added to or moved in the scene, but never shrinks).
setSceneRect:
QGraphicsScene::QGraphicsScene ( qreal x, qreal y, qreal width, qreal height, QObject * parent =
Constructs a QGraphicsScene object,
using the rectangle specified by (x, y), and the given width and height for its scene rectangle. The parent parameter is passed to QObject's
constructor.
例子:
可以使用setSceneRect()设置QGraphicsScene的大小。如果不设置,则默认为scene中包含所有子元素的边界区域( itemsBoundingRect()函数的返回值)
This property holds the scene rectangle; the bounding rectangle of the scene.
这个函数限定了场景边框。
The scene rectangle defines the extent of the scene. It is primarily used by QGraphicsView to
determine the view's default scrollable area, and by
QGraphicsScene to manage item indexing.
extent 长度
scrollable area 可滑动区间
index 参数
If unset, or if set to a null QRectF,
sceneRect() will return the largest bounding rect of all items on the scene since the scene was created (i.e., a rectangle that grows when items are added to or moved in the scene, but never shrinks).
setSceneRect:
QGraphicsScene::QGraphicsScene ( qreal x, qreal y, qreal width, qreal height, QObject * parent =
0 )
Constructs a QGraphicsScene object,using the rectangle specified by (x, y), and the given width and height for its scene rectangle. The parent parameter is passed to QObject's
constructor.
例子:
<span style="font-family:KaiTi_GB2312;font-size:18px;">Mainwindow.h: QGraphicsScene *scene; MainWindow.cpp: scene = new QGraphicsScene; scene->setSceneRect(-200,-200,400,400); </span>
QGraphicsScene::setSceneRect ( qreal x, qreal y, qreal w, qreal h ); 在调用这个函数时并不是setSceneRect(0,0,width,height),而是setSceneRect(-width/2,-height/2,width,height);即在QGraphicsView的坐标系统中Scene的原点并不是顶点而是中心点,与窗口的坐标系统不一致。
可以使用setSceneRect()设置QGraphicsScene的大小。如果不设置,则默认为scene中包含所有子元素的边界区域( itemsBoundingRect()函数的返回值)
相关文章推荐
- Servlet - Listener、Filter、Decorator
- 【bzoj2654]】tree
- ACM暑期集训——专题一[最短路Dijkstra算法]
- [置顶] Token原理以及应用
- 逻辑运算符的短路特性
- 线段树
- 小结:c# setter属性注入
- HDU 2087 剪花布条 kmp
- HDU 2066 一个人的旅行
- 发送短信验证码计时
- CSS伪类和伪元素的本质区别
- android天气预报(二)
- MFC文档读取TXT文件中的数据并传输到对话框中
- javascript基础
- HDU5363:Key Set
- 如何解决兼容性问题
- 【技巧】简单理解快速幂(求模)
- 【codefors】贪心
- java-基础-集合hashset
- UnicodeDecodeError: 'ascii' codec can't decode byte 0xc1 in position 7: ordinal not in range(128)