This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
IndoorMap/UIHelper.h
2016-05-24 16:55:19 +02:00

33 lines
686 B
C++

#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