How can i compare 2 icons?
-
Convert QPixmap to "QImage":QImage using method "toImage":http://qt-project.org/doc/qt-4.8/qpixmap.html#toImage and after that use "operator ==":http://qt-project.org/doc/qt-4.8/qimage.html#operator-eq-eq to compare.
-
First you have to make from QIcon to QPixmap (QIcon::pixmap(...)).
After this you have to convert from QPixmap to QImage (QPixmap::toImage()).The real comparison at the end:
@
bool ImageComp::pixelCompareImages( const QImage &a, const QImage &b )
{
if( a.size() != b.size() )
return false;
if( a.format() != b.format() )
return false;
for( int x=0; x<a.width(); ++x )
for( int y=0; y<a.height(); ++y )
if( a.pixel(x,y) != b.pixel(x,y) )
return false;
return true;
}
@