[Interest] Is it possible to use QPixmap from non guy thread in Qt5?

tang ke tangk at lemote.com
Thu Feb 14 14:32:40 CET 2013


yes, you can use the api code of platform.

with windows platform:

    int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
     int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
         HWND hDesktopWnd = GetDesktopWindow();
         HDC hDesktopDC = GetDC(hDesktopWnd);
         HDC hCaptureDC = CreateCompatibleDC(hDesktopDC);
         HBITMAP hCaptureBitmap = CreateCompatibleBitmap(hDesktopDC, 
nScreenWidth,
                         nScreenHeight);
         SelectObject(hCaptureDC, hCaptureBitmap);
         BitBlt(hCaptureDC, 0, 0, nScreenWidth, nScreenHeight, 
hDesktopDC, 0, 0,
                         SRCCOPY | CAPTUREBLT);


On 02/14/2013 04:15 PM, Иван Комиссаров wrote:
> In Qt4, i always got warning when trying to use QPixpap from thread other than the gui-thread.
>
> However i don't see that warning in Qt5. Also, documentation only says that i can use painter from non-gui thread on a QImage, but doesn't say that i can't use it on a pixmap:)
>
> Also, my test shows that i's possible to use painter on a pixmap in non-gui thread and there are no warnings in console.
>
> So, whom i should believe - my eyes or a QImage documentation?)
>
> Иван Комиссаров
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest


-- 
应用部  唐科
TEL : 0512-52308661-88686
FAX: 0512-52308688
MP : 18962393077
E-mail: tangk at lemote.com
地址:江苏省常熟市虞山镇梦兰工业园




More information about the Interest mailing list