I have created a main window with Qt Creator containing a QLabel named tracking_frame ...
How would I add mouse tracking to this QLabel only? - for example, outputting the coordinates (with respect to the QLabel) of a mouse click within the label.
I realise that I need to overwrite the protected member function: void mousePressEvent(QMouseEvent *event) inside tracking_frame and then create a function like so:
{
fprintf(stderr,"(x,y)=(%d,%d)\n",event->pos().x(),event->pos().y());
} // mousePressEvent()
void ??? ::mousePressEvent(QMouseEvent *event)
{
fprintf(stderr,"(x,y)=(%d,%d)\n",event->pos().x(),event->pos().y());
} // mousePressEvent()
To copy to clipboard, switch view to plain text mode
I am just unsure of where to place the
protected:
protected:
void mousePressEvent(QMouseEvent *event);
To copy to clipboard, switch view to plain text mode
(as the QLabel class definition is inside "ui_MainWindow.h" as it was all created in Qt Creator):
If I place it in the MainWin class definition in MainWindow.h the mouse tracking works but of course for anywhere in the main window...
What do I have to do?
I hope someone can help me out with this!
Hopefully it is a fairly straightforward procedure 
Cheers!
Bookmarks