• 4294阅读
  • 7回复

paintevent编译出错请教? [复制链接]

上一主题 下一主题
离线liuxin2005
 

只看楼主 倒序阅读 楼主  发表于: 2011-11-06
void MyButton::paintEvent( QPaintEvent *e)
{
Qrect  updateQ=e->rect();
}

paintEvent是 QT自身的构造函数,是一个inline内联函数实现:
  

293 class Q_GUI_EXPORT QPaintEvent : public QEvent  

294 {  

295 public:  

296     QPaintEvent(const QRegion& paintRegion);  

297     QPaintEvent(const QRect &paintRect);  

298     ~QPaintEvent();  

299    

300     inline const QRect &rect() const { return m_rect; }  

301     inline const QRegion &region() const { return m_region; }  

302    

303 #ifdef QT3_SUPPORT  

304     QT3_SUPPORT_CONSTRUCTOR QPaintEvent(const QRegion &paintRegion, const QRect &paintRect);  

305     inline QT3_SUPPORT bool erased() const { return m_erased; }  

306     inline QT3_SUPPORT void setErased(bool b) { m_erased = b; }  

307 #endif  

308    

309 protected:  

310     friend class QApplication;  

311     friend class QCoreApplication;  

312     QRect m_rect;  

313     QRegion m_region;  

314     bool m_erased;  

315 };  

编译时总是出错:invalied use the incomplte struct : paintevebt.
那位好心人士帮忙指出错误的原因,不胜感激!我是一个菜鸟,赶着交作业,请大侠们帮忙,谢谢
离线liuxin2005

只看该作者 1楼 发表于: 2011-11-06
Qrect  updateQ=e->rect();  出错的地方是在这里报的错误:invalied use the incomplte struct : paintevent
离线shaoshuai898

只看该作者 2楼 发表于: 2011-11-06
LZ是想实现什么样子功能的呀? 用update函数 重绘矩形?  可以画完矩形 在update?
离线jdwx

只看该作者 3楼 发表于: 2011-11-06
回 1楼(liuxin2005) 的帖子
void MyButton::paintEvent( QPaintEvent *e)
{
Qrect  updateQ=e->rect();
}
如果是复制过来的代码,Qrect 应该是QRect。
发帖时要说明:操作系统、Qt版本、编译器,这样能更快的得到回复。
离线liuxin2005

只看该作者 4楼 发表于: 2011-11-06
的确是复制过来的代码,本意应该是调用QPaintEven中的内联函数的rect的 :
inline const QRect &rect() const { return m_rect; }  ;
目前就是编译不过,如何调用rect呢?
离线liuxin2005

只看该作者 5楼 发表于: 2011-11-06
代码是: void CannonField::paintEvent(QPaintEvent *e)
{
    QRect updateR =e->rect();
.     .......
}
目前总是编译出错: invalid use of incomplete type ‘struct QPaintEvent* ’
离线jdwx

只看该作者 6楼 发表于: 2011-11-06
回 5楼(liuxin2005) 的帖子
#include <QPainterEvent>
发帖时要说明:操作系统、Qt版本、编译器,这样能更快的得到回复。
离线liuxin2005

只看该作者 7楼 发表于: 2011-11-06
it is ok,3ks..
niubility!!!!
快速回复
限100 字节
 
上一个 下一个