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.

1

Thursday, August 4th 2005, 11:21pm

embedding/importing graphics -solved

I've asked a similar question in the designer forum, but now I realize a more general question might also be useful. This is not the same question, it's an extension in general.

What ways are available to embed or import graphics into a Qt project (I'm using Qt 4) which allow the end product to not require external graphics files? I've seen simple bitmaps turned into arrays and included as a header file, but usually for very simple things like cursor shapes. Suppose I have a large, complicated graphic image, maybe a png or jpg, and I want to somehow permanently and statically embed it into an application...I'd have to serialize this and turn it into a data structure. Images which are compressed greatly complicate this. Is there some utility or general scheme to compile in images and make them available as a serialized data structure, rather than an outside file that has to be shipped with each project?

Note: I'm starting with png or jpg or other formats which can be exported by Gimp.

I guess I answered my own question, the Qt resource system does this!
-- "Quality is free", quoted from Dr. W. E. Deming

This post has been edited 2 times, last edit by "VirtualBrainSucker" (Aug 4th 2005, 11:26pm)


AP.Sakkthivel

Professional

  • "AP.Sakkthivel" is male

Posts: 563

Location: India

Occupation: Application Development Using Qt

  • Send private message

2

Friday, August 5th 2005, 8:02am

RE: embedding/importing graphics -solved

Yah i also look for the same solution...

In Qt3 we did using uic - embed option but here(from Jacek idea)

we can use resource files using Qt Designer but my question is

cant we embed images as include files as we did before.....

expecting reply


thanx in advance
Regards
- $akthi

You never know, how soon it may be too late…

3

Friday, August 5th 2005, 8:21am

RE: embedding/importing graphics -solved

You pretend the resource is a file but you use a colon ':' leading the file path name. So if you had file images/icon.png, you'd do QIcon(":/images/icon.png"). Then it understands it's the internally stored version.
-- "Quality is free", quoted from Dr. W. E. Deming