OpenHantek
QtAwesome Class Reference

#include <QtAwesome.h>

Inheritance diagram for QtAwesome:

Public Member Functions

 QtAwesome (QObject *parent=nullptr)
 The default icon colors. More...
 
virtual ~QtAwesome ()
 
void init (const QString &fontname)
 initializes the QtAwesome icon factory with the given fontname More...
 
bool initFontAwesome ()
 
void addNamedCodepoint (const QString &name, int codePoint)
 
QHash< QString, int > namedCodePoints ()
 
void setDefaultOption (const QString &name, const QVariant &value)
 Sets a default option. These options are passed on to the icon painters. More...
 
QVariant defaultOption (const QString &name)
 Returns the default option for the given name. More...
 
QIcon icon (int character, const QVariantMap &options=QVariantMap())
 
QIcon icon (const QString &name, const QVariantMap &options=QVariantMap())
 
QIcon icon (QtAwesomeIconPainter *painter, const QVariantMap &optionMap=QVariantMap())
 
void give (const QString &name, QtAwesomeIconPainter *painter)
 
QFont font (int size)
 
QString fontName ()
 Returns the font-name that is used as icon-map. More...
 

Private Attributes

QString fontName_
 The font name used for this map. More...
 
QHash< QString, int > namedCodepoints_
 A map with names mapped to code-points. More...
 
QHash< QString, QtAwesomeIconPainter * > painterMap_
 A map of custom painters. More...
 
QVariantMap defaultOptions_
 The default icon options. More...
 
QtAwesomeIconPainterfontIconPainter_
 A special painter fo painting codepoints. More...
 

Detailed Description

The main class for managing icons This class requires a 2-phase construction. You must first create the class and then initialize it via an init* method

Constructor & Destructor Documentation

◆ QtAwesome()

QtAwesome::QtAwesome ( QObject *  parent = nullptr)
explicit

The default icon colors.

◆ ~QtAwesome()

QtAwesome::~QtAwesome ( )
virtual

Member Function Documentation

◆ addNamedCodepoint()

void QtAwesome::addNamedCodepoint ( const QString &  name,
int  codePoint 
)

◆ defaultOption()

QVariant QtAwesome::defaultOption ( const QString &  name)

Returns the default option for the given name.

◆ font()

QFont QtAwesome::font ( int  size)

Creates/Gets the icon font with a given size in pixels. This can be usefull to use a label for displaying icons Example:

QLabel* label = new QLabel( QChar( icon_group ) ); label->setFont( awesome->font(16) )

◆ fontName()

QString QtAwesome::fontName ( )
inline

Returns the font-name that is used as icon-map.

◆ give()

void QtAwesome::give ( const QString &  name,
QtAwesomeIconPainter painter 
)

Adds a named icon-painter to the QtAwesome icon map As the name applies the ownership is passed over to QtAwesome

Parameters
namethe name of the icon
painterthe icon painter to add for this name

◆ icon() [1/3]

QIcon QtAwesome::icon ( int  character,
const QVariantMap &  options = QVariantMap() 
)

Creates an icon with the given code-point awesome->icon( icon_group )

◆ icon() [2/3]

QIcon QtAwesome::icon ( const QString &  name,
const QVariantMap &  options = QVariantMap() 
)

Creates an icon with the given name

You can use the icon names as defined on http://fortawesome.github.io/Font-Awesome/design.html withour the 'icon-' prefix

Parameters
namethe name of the icon
optionsextra option to pass to the icon renderer

◆ icon() [3/3]

QIcon QtAwesome::icon ( QtAwesomeIconPainter painter,
const QVariantMap &  optionMap = QVariantMap() 
)

Create a dynamic icon by simlpy supplying a painter object The ownership of the painter is NOT transfered.

Parameters
paintera dynamic painter that is going to paint the icon
optionmapthe options to pass to the painter

◆ init()

void QtAwesome::init ( const QString &  fontname)

initializes the QtAwesome icon factory with the given fontname

◆ initFontAwesome()

bool QtAwesome::initFontAwesome ( )

a specialized init function so font-awesome is loaded and initialized this method return true on success, it will return false if the fnot cannot be initialized To initialize QtAwesome with font-awesome you need to call this method

◆ namedCodePoints()

QHash<QString,int> QtAwesome::namedCodePoints ( )
inline

◆ setDefaultOption()

void QtAwesome::setDefaultOption ( const QString &  name,
const QVariant &  value 
)

Sets a default option. These options are passed on to the icon painters.

Field Documentation

◆ defaultOptions_

QVariantMap QtAwesome::defaultOptions_
private

The default icon options.

◆ fontIconPainter_

QtAwesomeIconPainter* QtAwesome::fontIconPainter_
private

A special painter fo painting codepoints.

◆ fontName_

QString QtAwesome::fontName_
private

The font name used for this map.

◆ namedCodepoints_

QHash<QString,int> QtAwesome::namedCodepoints_
private

A map with names mapped to code-points.

◆ painterMap_

QHash<QString, QtAwesomeIconPainter*> QtAwesome::painterMap_
private

A map of custom painters.


The documentation for this class was generated from the following files: