Hi everyone,
I'm using QTableView in a QWidget to show data from database. Users can click any cell in column 3 to play the music in that cell. Therefore I change the cursor to pointing hand when pointer entered the column and change it back to arrow when left.
Here is some related code:
m_view->setMouseTracking(true);
connect(m_view, SIGNAL(viewportEntered()), this, SLOT(changeCursor()));
if(index.column() == 3)
setCursor(Qt::PointingHandCursor);
else
setCursor(Qt::ArrowCursor);
}
void Tab::changeCursor(){
setCursor(Qt::ArrowCursor);
}
m_view->setMouseTracking(true);
connect(m_view, SIGNAL(clicked(QModelIndex)), this, SLOT(playAudio(QModelIndex)));
connect(m_view, SIGNAL(entered(QModelIndex)), this, SLOT(changeCursor(QModelIndex)));
connect(m_view, SIGNAL(viewportEntered()), this, SLOT(changeCursor()));
void Tab::changeCursor(QModelIndex index){
if(index.column() == 3)
setCursor(Qt::PointingHandCursor);
else
setCursor(Qt::ArrowCursor);
}
void Tab::changeCursor(){
setCursor(Qt::ArrowCursor);
}
To copy to clipboard, switch view to plain text mode
Everything works well except when I move pointer from column 3 to its header and leave the QTableView, the viewportEntered signal is not emitted and the cursor is keeping pointing hand but not arrow.
Could anyone help me with is issue? I'm using Qt 4.7.
Thanks in advance.
Bookmarks