The sliding window is implemented this time.
When I first thought about using a timer, I slide a little out at intervals, but I found some problems that could not be solved inexplicably. It seems to be related to the mechanism of the timer itself, so I had to give up. choose to use the sleep function that comes with windows, and repaint it at intervals.
Then, set a status value, click the mouse each time, and change its status. Based on this, determine whether the sliding time of the mouse works.
Code:
# Include <windows. h>
# Include <qmouseevent>
# Include <qmessagebox>
Floatingwindow: floatingwindow (qwidget * parent, QT: wflags flags)
: Qmainwindow (parent, flags)
{
Ui. setupui (this );
Ui. Pushbutton-> setflat (true );
Ui. Pushbutton-> setstylesheet ("background-image: URL (./PIC/2smallsetdown.jpg )");
UI. widget-> setgeometry (-UI. widget-> width (), UI. widget-> Y (), UI. widget-> width (), UI. widget-> height ());
// UI. widget-> setfeatures (qdockwidget: nodockwidgetfeatures );
Atout = false;
Status = true;
This-> setmousetracking (true );
// UI. widget-> setmousetracking (true );
Ui. centralwidget-> setmousetracking (true );
Ui. axwidget-> setmousetracking (true );
// Add flash
Connect (ui. axwidget, signal (fscommand (qstring, qstring), this, slot (flashaction (qstring, qstring )));
Ui. axwidget-> dynamiccall ("loadmovie (long, string)", 0, "E: // mlcn // topo_show.swf ");
Ui. axwidget-> dynamiccall ("Play ()");
}
Floatingwindow ::~ Floatingwindow ()
{
}
Void floatingwindow: mousemoveevent (qmouseevent * event ){
Int x = event-> X ();
Int y = event-> Y ();
If (Status)
{
If (x <20 & atout = false)
{
Movein ();
}
Else if (atout = true & x> 120)
{
Moveout ();
}
}
}
Void floatingwindow: movein (){
For (Pos =-UI. widget-> width (); POS <= 0; Pos = POS + 8)
{
Ui. widget-> setgeometry (qrect (Pos, UI. widget-> Y (), UI. widget-> width (), UI. widget-> height ()));
Ui. widget-> repaint ();
// UI. axwidget-> repaint ();
Sleep (1 );
}
Atout = true;
}
Void floatingwindow: moveout (){
For (Pos = 0; POS> =-UI. widget-> width (); Pos = pos-ui.widget-> width ())
{
Ui. widget-> setgeometry (qrect (Pos, UI. widget-> Y (), UI. widget-> width (), UI. widget-> height ()));
Ui. widget-> repaint ();
Ui. axwidget-> show ();
Sleep (1 );
}
Atout = false;
}
Void floatingwindow: mousedoubleclickevent (qmouseevent * event ){
Int x = event-> X ();
Int y = event-> Y ();
Int X1 = UI. widget-> X ();
Int Y1 = UI. widget-> Y ();
Int Wi = UI. widget-> width ();
Int he = UI. widget-> height ();
If (x> X1 & x <X1 + wi & Y> Y1 & Y <Y1 + He)
{
Status =! Status;
}
}
Void floatingwindow: flashaction (qstring command, qstring ARGs)
{
Qmessagebox: Information (this, command, argS );
}
Void floatingwindow: on_pushbutton_clicked ()
{
Status =! Status;
}
Void floatingwindow: on_pushbutton_2_clicked ()
{
Qapplication: exit ();
}