QPixmap ChangeImageColor(QPixmap sourcePixmap, QColor origColor, QColor destColor) { QImage image = sourcePixmap.toImage(); for (int w = 0; w < image.width(); ++w) for (int h = 0; h < image.height(); ++h) { QRgb rgb = image.pixel(w, h); if (rgb == origColor.rgb()) { ///替换颜色 image.setPixel(w, h, destColor.rgba()); } } return QPixmap::fromImage(image); }