You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

dfmax

Beginner

  • "dfmax" is male
  • "dfmax" started this thread

Posts: 22

Location: Slovenia

  • Send private message

1

Monday, January 10th 2005, 8:14pm

Icons in program

I'll use icons in my program. So what is the best/esiest way to use them?

2

Monday, January 10th 2005, 11:46pm

RE: Icons in program

add

Source code

1
IMAGES = image.png

to .pro file and than use pixmaps in code with

Source code

1
QPixmap::fromMimeSource( "image.png" )
Greetings
ar - OSZine

boosalis

Beginner

  • "boosalis" is male

Posts: 3

Location: Clovis California, USA

  • Send private message

3

Tuesday, January 11th 2005, 4:06am

RE: Icons in program

If you just have a few images or pixmaps the most reliable way is to use qembed to create a header file then include header in your source code. This way images(s) never get deleted or misplaced.

See qembed in QT Assistant, it is located in QTDIR/bin

For example
#include <imageFile.h> // generated by qembed


...
myIcon = new QIconSet();
image = qembed_findImage("imageName"); // macro defined in .h, so is image name
myIcon->setPixmap(QPixmap(image),QIconSet::Automatic,
QIconSet::Normal,QIconSet::On);

jacek

Master

  • "jacek" is male

Posts: 2,729

Location: Warsaw, Poland

  • Send private message

4

Tuesday, January 11th 2005, 8:40pm

RE: Icons in program

Quoted

Originally posted by boosalis
If you just have a few images or pixmaps the most reliable way is to use qembed to create a header file then include header in your source code.

All you have to do it to link your program with .cpp file generated by "uic -embed"[1] and
automagically, the default MIME factory will be populated with your images (provided that you don't
use KApplication) --- there is no need for including any files.

Then you can access your images with QImage::fromMimeSource or QPixmap::fromMimeSource.

[1] That's what qmake does with files from IMAGES variable.