void compareScreenshots(const QString &image1, const QString &image2) { QImage screenShot(image1); QImage original(image2); // cut away the title bar before comparing QDesktopWidget desktop; QRect desktopFrameRect = desktop.frameGeometry(); QRect desktopClientRect = desktop.availableGeometry(); QPainter p1(&screenShot); QPainter p2(&original); //screenShot.save("scr1.png", "PNG"); p1.fillRect(0, 0, desktopFrameRect.width(), desktopClientRect.y(), Qt::black); p2.fillRect(0, 0, desktopFrameRect.width(), desktopClientRect.y(), Qt::black); //screenShot.save("scr2.png", "PNG"); //original.save("orig1.png", "PNG"); QVERIFY(original == screenShot); }