The sending window jitter function is available in QQ and other chat software, which is now available in QT.
The main classes used are:QtimerAndQpoint
The qtimer class is used to enable the timer and place the window in different positions at different times. The effect is the jitter of the window. The qpoint class is used to locate the position (coordinates) of the window ).
The source code is as follows:
// Chardialog. h # ifndef chatdialog_h # define chatdialog_h # include <qdialog> namespace UI {class chatdialog;} class chatdialog: Public qdialog {q_object public: explicit chatdialog (personlogininfo * pb, qwidget * parent = 0 );~ Chatdialog (); Private: Ui: chatdialog * UI; private: qtimer * m_timer; int counter; qpoint curpos; Enum {maxlimittimes = 500 }; // Number of jitter Enum {maxlimitspace = 20}; // jitter amplitude Enum {shakespeed = 1000}; // jitter speed private slots: void s_timeout (); void slotshakewindow () ;}; # endif // chatdialog_h
// Chatdialog. CPP # include "chatdialog. H "# include" ui_chatdialog.h "chatdialog: chatdialog (personlogininfo * pb, qwidget * parent): qdialog (parent), UI (new UI: chatdialog) {UI-> setupui (this); m_timer = new qtimer (this); Connect (m_timer, signal (timeout (), this, slot (s_timeout ())); connect (ui-> shakewindow, signal (clicked (), this, slot (slotshakewindow (); counter = maxlimittimes;} void chatdialog: s_timeout () {If (counter <maxlimittimes) // No jitter ends {++ counter; Switch (counter % 4) {Case 1: {qpoint tmppos (curpos. X (), curpos. Y ()-maxlimitspace); this-> move (tmppos);} break; Case 2: {qpoint tmppos (curpos. X ()-maxlimitspace, curpos. Y ()-maxlimitspace); this-> move (tmppos);} break; Case 3: {qpoint tmppos (curpos. X ()-maxlimitspace, curpos. Y (); this-> move (tmppos);} break; Case 0: Default: This-> move (curpos); break ;}} else {m_timer-> stop () ;}} void chatdialog: slotshakewindow () {counter = 0; curpos = This-> pos (); m_timer-> Start (shakespeed );}
Message: I am a student, and I know nothing about it.
2014-07-24 03:21:53