initial commit
This commit is contained in:
32
UIHelper.h
Normal file
32
UIHelper.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef UIHELPER_H
|
||||
#define UIHELPER_H
|
||||
|
||||
#include <QImage>
|
||||
#include <QPainter>
|
||||
#include <QtSvg/QSvgRenderer>
|
||||
|
||||
class UIHelper {
|
||||
|
||||
public:
|
||||
|
||||
// static QIcon getIcon(const std::string& name) {
|
||||
// const std::string file = "://res/icons/" + name + "16.png";
|
||||
// QPixmap img(file.c_str());
|
||||
// return QIcon(img);
|
||||
// }
|
||||
|
||||
static QIcon getIcon(const std::string& name) {
|
||||
const int size = 32;
|
||||
const QColor fill = Qt::transparent;
|
||||
const std::string file = "://res/icons/" + name + ".svg";
|
||||
QSvgRenderer renderer(QString(file.c_str()));
|
||||
QPixmap pm(size, size);
|
||||
pm.fill(fill);
|
||||
QPainter painter(&pm);
|
||||
renderer.render(&painter, pm.rect());
|
||||
return QIcon(pm);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // UIHELPER_H
|
||||
Reference in New Issue
Block a user