Qt for windows消息循环、libqxt分析和wince快捷键处理 | 您所在的位置:网站首页 › qt中updatewindow › Qt for windows消息循环、libqxt分析和wince快捷键处理 |
Qt for windows 消息循环、 libqxt 分析和 wince 快捷键处理
利用 Qt 做 windows 图形界面开发和 MFC 相比,个人感觉还是比较简单好用的:首先 利用 Designer 工具搞个 ui 文件;然后在程序中写几个信号和槽;然后加载 ui 文件;最后显 示界面就搞定了。
在界面开发中,快捷键处理肯定是必不可少的。现在使用的是开源的第三方处理类: libqxt 。它提供跨平台的解决方案: win 和 x11 。使用起来也很方便。使用方便并不是万事大 吉,我们要有求索精神: “知其然知其所以然” 。好了废话不多说开始分析。
Windows 下程序设计总是要遵循它自身的机制的, 在《 windows 程序设计》 书中给出了 详细的说明。下面给出经典的 windows 程序示例( hello Windows ) :
#include
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ; int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) {
static TCHAR szAppName[] = TEXT ( "HelloWin" ) ; HWND hwnd ; MSG msg ; WNDCLASwndclass ; wndclass.style = CS_HREDRAW | CS_VREDRAW ; wndclass.lpfnWndProc = WndProc ; wndclass.cbClsExtra = 0 ; wndclass.cbWndExtra = 0 ; wndclass.hInstance = hInstance ; wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ; wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ; wndclass.hbrBackground= (HBRUSH) GetStockObject (WHITE_BRUSH) ; wndclass.lpszMenuNam = NULL ; wndclass.lpszClassName= szAppName ; if (!RegisterClass (&wndclass)) { MessageBox ( NULL, TEXT ( "This program requires Windows NT!" ), szAppName, MB_ICONERROR) ;
return 0 ; }
hwnd = CreateWindow( szAppName, // window class name
TEXT ( "The Hello Program" ), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
|
CopyRight 2018-2019 实验室设备网 版权所有 |