Home > Mobile >  The mouse tracking
The mouse tracking

Time:09-16

To open the code in the newly built QTabWidget class object, and its parent class mouse tracking, but still can't get coordinates, when the mouse on the excuse me what method?

CodePudding user response:

Is there, how to make the mouse in tabWidget open track and obtain relative to the coordinates of the control

CodePudding user response:

SetMouseTracking useless? How do you want to track?

CodePudding user response:

Just as I do not press the mouse left key of mouse can obtain real-time coordinates relative to the control, but not, although I have already set up mouse tracking
MainWindow: : MainWindow (QWidget * parent) :
QMainWindow (parent),
UI (new UI: : MainWindow)
{
The UI - & gt; SetupUi (this);
SetMouseTracking (true);
CentralWidget () - & gt; SetMouseTracking (true);
The UI - & gt; TabWidget - & gt; SetMouseTracking (true);
}

MainWindow: : ~ MainWindow ()
{
Delete the UI;
}

Void MainWindow: : mouseMoveEvent (QMouseEvent * e)
{
QPoint p=e - & gt; Pos ();
The UI - & gt; The label - & gt; SetText (QString (" % 1 and % 2 ")). Arg (p.x ()). Arg (p.y ()));
}

CodePudding user response:

Try to rewrite the base class QWidget enterEvent (QEvent *) events

CodePudding user response:

Mean rewriting tabWidget, then improve it??
  •  Tags:  
  • Qt
  • Related