i call this in my paintEvent, but nothing is paintet in the pixmap, why?
QObjectList ol = children();
{
if(o->isWidgetType())
{
QWidget* child
= qobject_cast<QWidget
*>
(o
);
QPainter::setRedirected(child
->paintEngine
()->paintDevice
(),
&widgetMask
);
}
}
QObjectList ol = children();
foreach(QObject *o, ol)
{
if(o->isWidgetType())
{
QWidget* child = qobject_cast<QWidget*>(o);
QPainter::setRedirected(child->paintEngine()->paintDevice(), &widgetMask);
}
}
To copy to clipboard, switch view to plain text mode
and than i update the pixmap onto my layered Window
HBITMAP oldBitmap;
HBITMAP hBitmap;
SIZE size;
size.cx = widgetMask.width();
size.cy = widgetMask.height();
HDC screenDc = GetDC(NULL);
POINT pointSource;
pointSource.x = 0;
pointSource.y = 0;
POINT topPos;
topPos.x = x();
topPos.y = y();
HDC memDc = CreateCompatibleDC(screenDc);
BLENDFUNCTION blend;
blend.BlendOp = AC_SRC_OVER;
blend.BlendFlags = 0;
blend.SourceConstantAlpha = alpha;
blend.AlphaFormat = AC_SRC_ALPHA;
hBitmap
= widgetMask.
toWinHBITMAP(QPixmap::PremultipliedAlpha);
// grab a GDI handle from this GDI+ bitmap oldBitmap = (HBITMAP)SelectObject(memDc, hBitmap);
UpdateLayeredWindow(winId(), screenDc, &topPos, &size, memDc, &pointSource, 0, &blend, ULW_ALPHA);
//
ReleaseDC( NULL, screenDc);
if (hBitmap != NULL)
{
SelectObject(memDc, oldBitmap);
//DeleteObject(hBitmap); // The documentation says that we have to use the Windows.DeleteObject... but since there is no such method I use the normal DeleteObject from Win32 GDI and it's working fine without any resource leak.
DeleteObject(hBitmap);
}
DeleteDC(memDc);
HBITMAP oldBitmap;
HBITMAP hBitmap;
SIZE size;
size.cx = widgetMask.width();
size.cy = widgetMask.height();
HDC screenDc = GetDC(NULL);
POINT pointSource;
pointSource.x = 0;
pointSource.y = 0;
POINT topPos;
topPos.x = x();
topPos.y = y();
HDC memDc = CreateCompatibleDC(screenDc);
BLENDFUNCTION blend;
blend.BlendOp = AC_SRC_OVER;
blend.BlendFlags = 0;
blend.SourceConstantAlpha = alpha;
blend.AlphaFormat = AC_SRC_ALPHA;
hBitmap = widgetMask.toWinHBITMAP(QPixmap::PremultipliedAlpha); // grab a GDI handle from this GDI+ bitmap
oldBitmap = (HBITMAP)SelectObject(memDc, hBitmap);
UpdateLayeredWindow(winId(), screenDc, &topPos, &size, memDc, &pointSource, 0, &blend, ULW_ALPHA);
//
ReleaseDC( NULL, screenDc);
if (hBitmap != NULL)
{
SelectObject(memDc, oldBitmap);
//DeleteObject(hBitmap); // The documentation says that we have to use the Windows.DeleteObject... but since there is no such method I use the normal DeleteObject from Win32 GDI and it's working fine without any resource leak.
DeleteObject(hBitmap);
}
DeleteDC(memDc);
To copy to clipboard, switch view to plain text mode
Bookmarks