I have a class that inherits by QTreeWidget, how can I know the actually selected row? I explain, usually we connect signals to slots by this way:
connect(myButton, SIGNAL(triggered(bool)), this, SLOT(myClick()));
I can't find nothing to similar for QTreeWidget->QTreeWidgetItem. The only way I found is this: redefining the mousePressEvent of QTreeWidget class like this
void MyQTreeWidget::mousePressEvent(QMouseEvent *e){
QTreeView::mousePressEvent(e);
const QModelIndex index = indexAt(e->pos());
if (!index.isValid())
{
const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
if (!(modifiers & Qt::ShiftModifier) && !(modifiers & Qt::ControlModifier))
clearSelection();
}
}
I didn't try it yet. Can anybody tell me if this is the unique solution or if there is a simplest way? Thanks