Qt学习笔记1
2012-07-22 15:14 owenyang 阅读(474) 评论(0) 编辑 收藏 举报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);