1.点击按钮弹窗
【效果表现】:
点击按钮弹窗,并显示到最上面,然后鼠标点击弹窗外其他区域,弹窗关闭。
【代码实现】:
首先自定义一个dialog,将该dialog的属性设置如下:
setWindowFlags(Qt::Popup | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint);
2.鼠标移入按钮弹出移出按钮关闭弹窗
【效果表现】:
鼠标移入按钮,显示弹窗,鼠标移出按钮,弹窗关闭。
【代码实现】:
先把所有的button和弹窗对象安装到过滤器:
然后重写主窗口的eventFilter,如下:
bool CameraMapDlg::eventFilter(QObject *watched, QEvent *event)
{
//qDebug()<<"--eventFilter--";
int type = 0;
QPoint curCursorPosPt = cursor().pos();
QMapIterator<IrregularButton*,QStringList> it(m_mBtnCameraNumListMap);
while(it.hasNext()){
it.next();
//qDebug()<<"--eventFilter--001";
Irregula