4 #ifdef QT_NO_SVGRENDERER 5 #error "QT_NO_SVGRENDERER defined" 11 #include <QTextStream> 17 inline QIcon
LoadSvgIcon(QString filename, QString style_name =
"light")
20 file.open(QFile::ReadOnly | QFile::Text);
21 auto svg_data = file.readAll();
24 if( style_name.contains(
"light") )
26 svg_data.replace(
"#000000",
"#111111");
27 svg_data.replace(
"#ffffff",
"#dddddd");
30 svg_data.replace(
"#000000",
"#dddddd");
31 svg_data.replace(
"#ffffff",
"#111111");
34 QByteArray content(svg_data);
36 QSvgRenderer rr( content );
37 QImage image(64, 64, QImage::Format_ARGB32);
38 QPainter painter(&image);
39 image.fill(Qt::transparent);
42 return QIcon(QPixmap::fromImage(image));
46 #endif // PJ_SVG_UTIL_H QIcon LoadSvgIcon(QString filename, QString style_name="light")