What function can I replace the QPaintDeivce::handle() function from Qt 3 in Qt 4 with?

In Qt 3 all of the paint devices were tied one-to-one with an underlying object. QPixmap [doc.qt.nokia.com] was a Windows HBITMAP or X11 pixmap for example. This tight connection between native and Qt classes no longer exists in Qt 4, but we have created mappings in the places where connections do exist. Toplevel widgets have a winId() [qt.nokia.com] for example and QPixmap a to/ fromWinHBITMAP() [qt.nokia.com], QWidget has getDc() [qt.nokia.com] and releaseDC() [doc.qt.nokia.com] etc.

So the new functions are spread over several classes and in most cases you could simply use one of the new alternatives. If you want to convert between Windows bitmaps and our pixmaps for example then you could use QPixmap::fromWinHBITMAP().

If you wish to use GDI directly on the widget then this is more tricky since all drawing happens in the backingstore, so you would also have to draw with GDI on it. That could be achieved in the paintEvent() [doc.qt.nokia.com] by calling

  1. painter.paintEngine()->getDC()

and then later releaseDC().

No comments

Write a comment

Sorry, you must be logged in to post a comment.