mirror of
https://github.com/gamecreature/QtAwesome.git
synced 2025-12-18 12:44:35 +03:00
fix #29, extra options to take in account the on/off state.
Updated/extended sample and README.md
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -19,15 +21,42 @@ int main(int argc, char *argv[])
|
||||
QtAwesome* awesome = new QtAwesome(&w);
|
||||
awesome->initFontAwesome();
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
|
||||
// a simple beer button
|
||||
QPushButton* beerButton = new QPushButton( "Cheers!");
|
||||
//=====================
|
||||
{
|
||||
QPushButton* beerButton = new QPushButton( "Cheers!");
|
||||
|
||||
QVariantMap options;
|
||||
options.insert("anim", qVariantFromValue( new QtAwesomeAnimation(beerButton) ) );
|
||||
beerButton->setIcon( awesome->icon( fa::beer, options ) );
|
||||
|
||||
layout->addWidget(beerButton);
|
||||
}
|
||||
|
||||
// a simple beer checkbox button
|
||||
//==============================
|
||||
{
|
||||
QPushButton* toggleButton = new QPushButton("Toggle Me");
|
||||
toggleButton->setCheckable(true);
|
||||
|
||||
QVariantMap options;
|
||||
options.insert("color", QColor(Qt::green) );
|
||||
options.insert("text-off", QString(fa::squareo) );
|
||||
options.insert("color-off", QColor(Qt::red) );
|
||||
toggleButton->setIcon( awesome->icon( fa::checksquareo, options ));
|
||||
|
||||
|
||||
QVariantMap options;
|
||||
options.insert("anim", qVariantFromValue( new QtAwesomeAnimation(beerButton) ) );
|
||||
beerButton->setIcon( awesome->icon( fa::beer, options ) );
|
||||
layout->addWidget(toggleButton);
|
||||
}
|
||||
|
||||
|
||||
// add the samples
|
||||
QWidget* samples = new QWidget();
|
||||
samples->setLayout(layout);
|
||||
w.setCentralWidget(samples);
|
||||
|
||||
w.setCentralWidget( beerButton );
|
||||
w.show();
|
||||
|
||||
return app.exec();
|
||||
|
||||
Reference in New Issue
Block a user