Created
May 18, 2015 11:54
-
-
Save vladon/d02ae31690cc2fa8a8fa to your computer and use it in GitHub Desktop.
Transition from Qt4 to Qt5: one overloaded version of QPainter:drawPixmapFragments absent in Qt5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void drawPixmapFragments(QPainter *painter, const QRectF *targetRects, const QRectF *sourceRects, int fragmentCount, | |
const QPixmap &pixmap, QPainter::PixmapFragmentHints hints) | |
{ | |
for (int i = 0; i < fragmentCount; ++i) { | |
QRectF sourceRect = (sourceRects) ? sourceRects[i] : pixmap.rect(); | |
QPainter::PixmapFragment pixmapFragment = | |
QPainter::PixmapFragment::create( | |
targetRects[i].center(), | |
sourceRects[i], | |
targetRects[i].width() / sourceRect.width(), | |
targetRects[i].height() / sourceRect.height() | |
); | |
painter->drawPixmapFragments(&pixmapFragment, 1, pixmap, hints); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In Qt5 the function
QPainter::drawPixmapFragments
with five arguments was deprecated:This function does not exists in Qt5.
This gist is the helper for transition, call it as before in Qt4, but first parameter is the pointer to your QPainter instance.