PDA

View Full Version : Differentiating single-clicks and double-clicks in a QTreeWidget



adamb924
20th December 2010, 16:58
I would like to have different program behavior when a user single-clicks or double-clicks an item in a QTreeWidget. As it happens, when I double-click an item two signals are emitted: itemClicked and itemDoubleClicked. Is there a way around this?

Thanks,
Adam

Lykurg
20th December 2010, 17:06
You have to reimp QTreeView::mousePressEvent() and QTreeView::mouseDoubleClickEvent() yourself and emit e.g custom signals.

Zlatomir
20th December 2010, 18:51
QTreeWidget (http://doc.qt.nokia.com/stable/qtreewidget.html) already has signals:

void itemClicked ( QTreeWidgetItem * item, int column )
void itemDoubleClicked ( QTreeWidgetItem * item, int column )
See all it's signals here (http://doc.qt.nokia.com/stable/qtreewidget.html#signals)