Menu Content/Inhalt
Home
Welcome To Canna Software

Canna Software is dedicated to embedded systems development. We have over 25 years of experience working at all levels of hardware and software design. If you have heard of it or it is in the news, odds are we have developed with it.

When you need a new project designed in a short period of time, call Canna Software.

Canna Software: We Write the Code You Want

 
Hack QT3 to compile embedded images cleanly PDF Print E-mail
Written by Webmaster   
Thursday, 27 March 2008
Image
Linux/QT3
One of the issues I see come up time and time again is how to use embedded images in QT programs. The problem is that the "solution" from Trolltech just doesn't seem to work. So how do you get QT3 to handle embedded images? By hacking it of course! Solution below the fold...

My solution is simplicity in itself. This can be done either from KDevelop (QMake tab to the right, subproject settings, custom variables) or a change to src.pro. Let's examine the GUI solution first.

1. Create a custom variable named QMAKE_UIC and assign it the value of "hack.sh" (but without the quotes). Apply, and exit.

2. Next, create the following file "hack.sh" and put the following in it:

#!/bin/bash

if [ $1 == -embed ]; then
    echo "== hack.sh substituted for uic so image collection works =="
    uic $* cat hack.cpp >> qmake_image_collection.cpp
else
    uic $*
fi
 
3. Now change the file permissions so we can execute it:
 
     chmod 755 hack.sh
 
4. This is the second file we need to create is "hack.cpp" and it needs to have the following:

// This is a hack to make rebuilding this work. Note that during the build process this gets tacked
// on to the uic_image_collection.cpp file.

QImage canna_findImage( const QString& name )
{
    return(uic_findImage(name));
}

Now, anytime we want to pull up an embedded image, we use the function canna_findimage("yourstringhere.png").
Last Updated ( Thursday, 27 March 2008 )
 
< Prev   Next >