我想实现在QWebview的页面上通过mouseDoubleClickEvent事件构建一个button,通过单击button来关闭QWebview页面,
void MainWdget::mouseDoubleClickEvent(QMouseEvent *mouseEvent)
{
qDebug()<<"mouseDoubleClicked";
quitButton = new QPushButton("Quit");
quitButton->show();
connect(quitButton, SIGNAL(click()), this, SLOT(close()));
}
但是无法关闭???
Qt?C++
------解决方案--------------------
mouseDoubleClickEvent不是双击吗?单击能成功吗?
------解决方案--------------------
你的button应该形成了一个单独的窗口控件,你构造的时候传this进去
void MainWdget::mouseDoubleClickEvent(QMouseEvent *mouseEvent)
{
qDebug()<<"mouseDoubleClicked";
quitButton = new QPushButton("Quit", this);
quitButton->show();
connect(quitButton, SIGNAL(click()), this, SLOT(close()));
}
------解决方案--------------------
那这个就必须自己去处理了,因为你是重写MainWdget的mouseDoubleClickEvent
那么在这个窗体的任何区域都会去响应mouseDoubleClickEvent,你的链接在这个里面当然也会响应