首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > QT开发 >

qt event没有执行,该如何处理

2012-04-20 
qt event没有执行我想让鼠标进入和离开widget(spreenSplash类型的窗口)时,显示不同的光标,因此重写了leave

qt event没有执行
我想让鼠标进入和离开widget(spreenSplash类型的窗口)时,显示不同的光标,因此重写了leaveEvent和enterEvent,但是没有起作用。请教,问题可能出在哪里?

C/C++ code
void SplashScreen::enterEvent( QEvent* event ){   if( event->type() == QEvent::Enter )   {      QCursor cursor( Qt::WaitCursor );      this->setCursor( cursor );   }}void SplashScreen::leaveEvent( QEvent* event ){   if( event->type() == QEvent::Leave )   {      QCursor cursor( Qt::ArrowCursor );      this->setCursor( cursor );   }}



[解决办法]
不用加if( event->type() == QEvent::Enter )
直接
C/C++ code
void SplashScreen::enterEvent( QEvent* event ){      QCursor cursor( Qt::WaitCursor );      this->setCursor( cursor );}
[解决办法]
要设置mousetracking属性吧

This property holds whether mouse tracking is enabled for the widget.

If mouse tracking is disabled (the default), the widget only receives mouse move events when at least one mouse button is pressed while the mouse is being moved.

If mouse tracking is enabled, the widget receives mouse move events even if no buttons are pressed.

Access functions:

boolhasMouseTracking () const
voidsetMouseTracking ( bool enable )

热点排行