• 5298阅读
  • 1回复

请教一个QGraphicsLineItem增加slot的问题 [复制链接]

上一主题 下一主题
离线jfzhang
 
只看楼主 倒序阅读 楼主  发表于: 2010-04-10
我的程序要完成这样的功能:点击一条线,然后这条线条从黑色变为红色,同时弹出对话框,当这个对话框关闭时,线条颜色也同时从红色变为黑色。我的实现方法是,对话框继承QWidget类,重写closeEent虚函数,完成当对话框关闭时抛出自定义的信号coseS(),因为我要在实现线条颜色也同时从红色变为黑色,所以我就在继承QGraphicsLineItem的线条类中定义了SLOT,此时问题出现了,编译错误如下:
/home/jfzhang/plotnode/moc/moc_line.cpp:44: error: ‘staticMetaObject’ is not a member of ‘QGraphicsLineItem’
/home/jfzhang/plotnode/../qtsdk-2010.02/qt/include/QtCore/qobject.h:296: error: ‘QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> > QObject::d_ptr’ is protected
/home/jfzhang/plotnode/moc/moc_line.cpp:54: error: within this context
/home/jfzhang/plotnode/../qtsdk-2010.02/qt/include/QtCore/qobject.h:296: error: object missing in reference to ‘QObject::d_ptr’
/home/jfzhang/plotnode/moc/moc_line.cpp:54: error: from this location
/home/jfzhang/plotnode/../qtsdk-2010.02/qt/include/QtCore/qobject.h:296: error: ‘QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> > QObject::d_ptr’ is protected
/home/jfzhang/plotnode/moc/moc_line.cpp:54: error: within this context
/home/jfzhang/plotnode/../qtsdk-2010.02/qt/include/QtCore/qobject.h:296: error: object missing in reference to ‘QObject::d_ptr’
/home/jfzhang/plotnode/moc/moc_line.cpp:62: error: ‘qt_metacast’ is not a member of ‘QGraphicsLineItem’
/home/jfzhang/plotnode/moc/moc_line.cpp:67: error: ‘qt_metacall’ is not a member of ‘QGraphicsLineItem’
难道QGraphicsLineItem不能写SLOT或是SIGNAL
离线jfzhang
只看该作者 1楼 发表于: 2010-04-10
我查了一下,是因为模板类类不能使用信号和槽,但是怎么实现我说的那个功能呢?请问大侠们
快速回复
限100 字节
 
上一个 下一个