QT-定制标题栏支持窗口移动

	主要实现三个函数
	
	void testDlg::mousePressEvent( QMouseEvent * e )	
	{
		if ( e->buttons() & Qt::LeftButton
		 &&  e->pos().y() <= ui.title->height() )
		{
			m_bIsDrag = true;
			m_pt = e->globalPos() - geometry().topLeft();
			e->accept();
		}
	}
			
	void testDlg::mouseMoveEvent( QMouseEvent * e )
	{
		if ( e->buttons() & Qt::LeftButton )
		{
			if ( m_bIsDrag && e->pos().y() <= ui.title->height() )
			{
				move( e->globalPos() - m_pt );
				e->accept();
			}
		}
	}
			
	void testDlg::mouseReleaseEvent( QMouseEvent * e )
	{
		if ( m_bIsDrag )
		{
			move( e->globalPos() - m_pt );
			e->accept();
			m_bIsDrag = false;
		}
	}

你可能感兴趣的:(非主线笔记)