Recently, when I wrote mousetracking about the mouse, I found that there were some problems with moving irregular forms, so I moved the form again.CodeSorting Optimization
Add the function as follows so that you can call it directly.
Add the following to the CPP file:
------------- I am a gorgeous demarcation line ----------------
Void mainwindow: mousemoveevent (qmouseevent * E)
{
If (e-> buttons () & QT: leftbutton ){
Qpoint newpos = e-> globalpos ();
Qpoint upleft = pos0 + newpos-last;
Move (upleft );
}
}
Void mainwindow: mousepressevent (qmouseevent * E)
{
If (e-> button () = QT: leftbutton ){
Last = e-> globalpos ();
Pos0 = e-> globalpos ()-E-> pos ();
}
}
Add the following in. h:
------------- I am a gorgeous demarcation line ----------------
Public:
Qpoint last, pos0; // window mobile Processing
Protected:
Void changeevent (qevent * E );
Void mousemoveevent (qmouseevent *);
Void mousepressevent (qmouseevent *);
# Include "qmouseevent"