[Qt-interest] Mouse click on QTextBrowser.
Niegodziwy Beru
niegodziwy.beru at gmail.com
Thu Mar 18 15:30:07 CET 2010
Hi. I create simple application which show QDialog with QTextBrowser
inside. I use Qt::Popup to create dialog, so I don't have close
button.
Problem: I want to close this dialog when user click on html control.
"clicked()" signal is not suported by QTextBrowser, I try also
eventFilter() where I catch QEvent::MouseButtonDblClick,
QEvent::MouseButtonPress but that doesn't work. I will be grateful for
any help.
Example:
Dialog::Dialog(QWidget *parent, Qt::WindowFlags flags) :
QDialog(parent, flags | Qt::Popup) {
QVBoxLayout* lay = new QVBoxLayout;
setLayout(lay);
brw = new QTextBrowser;
lay->addWidget(brw);
brw->setText("simple text");
brw->installEventFilter(this);
brw->show();
}
bool Dialog::eventFilter(QObject* target, QEvent* event) {
if(target == brw &&
(event->type() == QEvent::MouseButtonPress ||
event->type() == QEvent::MouseButtonDblClick ||
event->type() == QEvent::MouseButtonRelease))
{
qDebug("close()");
close();
return true;
}
return QDialog::eventFilter(target, event);
}
--
Ad maiorem Dei gloriam
More information about the Qt-interest-old
mailing list