QT-mouseMoveEvent()不响应

  迷惑了我两天,最终莫名其妙得又可以响应了。。。

  我做的是在主窗口下的QLabel的mouseMoveEvent()的响应。

   解决方案一:

    若实在响应不了,可采取在控件类中重写eventFilter(),专门去处理mouseMove事件,不去再用mouseMoveEvent。

bool QEVFPictureBox::eventFilter(QObject *o, QEvent *e)
{
	static bool i = false;
	if ((o == this) && (e->type() == QEvent::MouseMove))
	{
		if (i = !i) return true;
		QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(e);
		if (mouseEvent->buttons() == Qt::LeftButton && !m_ptMousePress.isNull())
		{
			// process    

			return true;
		}
	}
	return false;
}

解决方案二:

当你在网上查了很多方法后,莫名其妙的又可以响应了。。。骂人

猜你喜欢

转载自blog.csdn.net/qq_26399665/article/details/80266720