This function is called when it comes time to write the class to file. The
only thing asked of the component is to write out all the functions necesary
to make the widget in the code look like this one, signal connections,
function writing etc will be done by QtEZ.
This is done with a pair of functions:
- writeInParent(QString toWrite);
- writeLine(QString toWrite);
Only different between the two is writeInParent() will make this a call to
your object as necesary, ie it will prepend 'yourClassInstance->' to
toWrite as necesary, if this should never happen then use writeLine(), most
should be writeInParent() though. It should also be noted you should put
the ending semi-colon and \n onto the the line as you want it to look in
the final output, do not worry about putting tabs before your lines though
this will be handled by QtEZ.
It is often the case with writing these that the person hasn't changed the
attribute in question to cause this line to be written, for example if they
don't change the caption from it's default, why should you write out
'setCaption("the new caption");\n'? This being the case there is a facility
for you, you will want to check if
isWritten("The Attribute Caption in Question") == 1. for example:
if(isWritten("Caption"))
{
i.sprintf("setCaption(\"%s\");\n",look->caption());
writeInparent(i);
}
This should allow you to write only the necesary calls, and keep the
generated source code to a minimum, again this isn't necesary but it will
speed up compilation on your component and in the long run safe you and
users of the component time, so it is a Good Thing (tm). There is a macro
to help this a little it is:
i.sprintf("setCaption(\"%s\");\n",look->caption());
WRITEATTRIB("Caption",i);
This is approximatly the same thing, and will make it a little easier on
you, though if you have multiple attributes you depend on, for example
width and height, before writing the setGeometry() call, then you will
need to use the first construct.
virtual char *queryQType();
This is used to 'show' what type of component this is, for example if the
component you are creating is a QWidget, you will want to return
"QWidget" there, that will result in that type being shown in QtEZ
environment, it will also be used as the class type if the
specialInher()
function isn't defined. The main reason for this function is for a
consistant look, for example if you are implimenting a component that is
either a QMenuBar or a KMenubar depending on what kind of application the
user has selected it is recommended you return one string in the
queryQType(), something like "Menubar", and then return either QMenubar,
or KMenuBar in specialInher() as required, this allows for a more
consistant look in QtEZ.