Qt学习之路(30): Graphics View Framework
时间:2010-12-02 来源:siriurs28
#include <QtGui> |
为了突出重点,我们就直接include了QtGui,不过在实际应用中不建议这么做。这里提供了直线的两种实现:一个是DrawApp使用我们前面介绍的技术,重写paintEvent()函数,这里就不在赘述,重点来看main()函数里面的实现。 首先,我们创建了一个QGraphicsScene作为场景,然后在scene中添加了一个直线,这样就把我们需要的图形元件放到了scene中。然后创建一个QGraphicsView对象进行观察。就这样,我们就是用Graphics View搭建了一个最简单的应用。运行这个程序来看结果:

