I'm just learning QT with C++. I have successfully implemented signals and slots to trap standard events like ButtonPushed(), etc. However, I want to have a function called when I mouse over and mouse out of a QLabel. It looks like QHoverEvent will do what I need, but I can't seem to find any tutorials or examples on how to implement this? Is it done the same way as signals and slots? I tried:
connect(ui.lbl_test, SIGNAL(QHoverEvent), this, SLOT(TestFunc(QEvent::Type type, const QPoint & pos, const QPoint & oldPos)));
.. but the function didn't get called when I hovered over the label.
Here is the function, listed in the header file as a public slot:
void MyDialog::TestFunc(QEvent::Type type, const QPoint & pos, const QPoint & oldPos) {
QMessageBox::information(this, tr("Hey"), tr("Listen!"));
}
Can anyone help me figure this out or point me to a good example?
EDIT:
After reading a post below, I found no setFlag() member to call for my label widget, but I did try:
ui.lbl_test->setMouseTracking(true);
connect(ui.lbl_test, SIGNAL(ui.lbl_test->mouseMoveEvent()), this, SLOT(TestFunc(QMouseEvent *event)));
And updated TestFunc() accordingly. But still nothing happens when I mouse over.
After looking I am not sure QLabel even inherits the mouseMoveEvent() even from QWidget. If this is true, is there a widget that does, or a list of objects that inherit it somewhere? All I can tell from the documentation on their site is how many inherited functions an object has..