PDA

View Full Version : Can I paint on Qt widget by invoking win32 sdk api?



mendynew
24th March 2008, 11:24
Can I paint on Qt widget by invoking win32 sdk api?
The code is below, it seems that do not work.
I want to implement such function for some special aim.


PAINTSTRUCT ps;
HWND hwnd = (HWND)winId();
HDC hdc = BeginPaint(hwnd,&ps);
::MoveToEx(hdc, 0, 0, NULL);
bool stat = ::LineTo(hdc, 500, 500);
EndPaint(hwnd,&ps);

The codes are all in function paintEvent.

yogeshm02
24th March 2008, 14:37
I'm not sure but think this is possible. If I remember correctly I once drew using X libs on Linux (not sure even about the Qt version I used then), so likewise this might also be possible on Windows. Where is the referred code placed in the class and are you sure it didn't work{Ok, got it now}, I meant Qt might have drawn something on it afterwards.

mendynew
25th March 2008, 02:33
I'm not sure but think this is possible. If I remember correctly I once drew using X libs on Linux (not sure even about the Qt version I used then), so likewise this might also be possible on Windows. Where is the referred code placed in the class and are you sure it didn't work{Ok, got it now}, I meant Qt might have drawn something on it afterwards.

The codes are placed in function paintEvent.