用
creator生成了一个程序,
编译运行都没
问题。
现在通过add new增加了一个.cpp源码,目的是建一个自定义的QGraphicsItem,内容如下
然后编译时就出问题了,提示undefined reference to 'vtable for MyItem'
在网上搜了一下,似乎是需要
moc预处理,但不知怎么加到.pro文件中或Makefile里,
次外,我看到的example程序里,类似的情况可以编译通过,不知我的代码里少了哪些关键的语句?
我试过分成2部分放到.h和.cpp文件中,同样
出错。
- #include <QGraphicsItem>
- class MyItem : public QGraphicsItem
- {
- public:
- MyItem(QGraphicsItem *parent = 0);
- void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget =0);
- };
- MyItem::MyItem(QGraphicsItem *parent)
- {
- }
[ 此帖被omss在2011-04-04 10:46重新编辑 ]