1.Qt引用API時,QString到LPCWSTR的轉換:
::GetPrivateProfileIntW(QString(tr("相關設置")).utf16(),QString(tr("時間間隔")).utf16(),5,filePath.utf16()));
?
2.引用LPRECT時:
RECTappRect;
::GetWindowRect(AppWnd,(LPRECT)&appRect);
?
3.模擬按鍵與鼠標:
???MousePoint=QCursor::pos();
? ? ? ??::SetCursorPos(youDaoRect.x()+100,youDaoRect.y()+200);
???mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
??? ?mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
??? ?keybd_event(VK_SPACE,0,0,0);
???keybd_event(VK_SPACE,0,2,0);
? ? ? ???::SetCursorPos(MousePoint.x(),MousePoint.y());
?
4.Qt應用程序創建圖標:
???????? a.工程文件夾,新建:icon.rc????
???????? b.添加文本:IDI_ICON1 ? ? ? ?? ? ? ICON ? ? ? ? ? ? ?? ? ?"yo.ico"
???????? c.*.pro文件里,加入代碼:?????? RC_FILE?=?icon.rc
???????? d.搞定。
?
5.Qt timer的用法:
???????? a.頭文件:
? ? ? ? ?#include<QtCore>
???????? b.構造函數里添加聲明:
??????? QTimer*timer = newQTimer(this);
???????? ? ? ??connect(timer,SIGNAL(timeout()),this,SLOT(timerUpDate()));
? ? ? ? ?c.添加槽:
???????privateslots:
?????? ? ??? ?voidtimerUpDate();
??? d.相應事件設置周期,與開始即可:
??????? timer->start(ui->spinBox->value()*1000);
?
6.Qt 重寫關閉事件:????????
voidcloseEvent(QCloseEvent*e);
?