View Full Version : Qtreewidget

4th May 2009, 11:07
i have a qdialog. And i want to open this dialog when clicked on treewidget or focus on treewidget.. not clicked on treewidgetitem...

how can i do it?

4th May 2009, 12:09
install event filter on a treewidget's viewport and process needed events.

bool MyWidget::eventFilter(QObject *o, QEvent *e)
if (m_treeWidget->viewport() == o) {
if (e->type() == QEvent::MouseButtonPress) {
const QMouseEvent *me = static_cast<QMouseEvent>(e);
//add whatever you want
} else if (e->type() == QEvent::FocusIn) {
//add whatever you want
return QWidget::eventFilter(o, e);

PS. please, ask questions like this in Newbie forum.