#include <qpixmapcache.h>#include <qpushbutton.h>extern QPixmapCache *pc;class aaa : public QPushButton{ Q_OBJECT public: aaa( const QString & text, QWidget * parent, const char * name = 0 ):QPushButton( text, parent, name ){ setIconSet( *pc->find("pic")); } ~aaa(){} public slots: void aaaa(){ aaa *a = new aaa("zzzzz",0); a->show(); }};
#include "cls.h"QPixmapCache *pc=NULL;
#include <qapplication.h>#include <qpixmapcache.h>#include <qpushbutton.h>#include "cls.h"int main( int argc, char ** argv ){ QApplication a( argc, argv ); pc->insert("pic",QPixmap("/path_to/a.png")); aaa b("butt",0); a.setMainWidget ( &b ); a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) ); a.connect( &b, SIGNAL( clicked() ), &b, SLOT( aaaa() ) ); b.show(); return a.exec();}
pc = new QPixmapCache(...);
pc->insert("pic",QPixmap("/path_to/a.png"));
QPixmapCache::insert("pic",QPixmap("/path_to/a.png"));