venerdì 14 marzo 2008

Set text into Label component

In Symbian, a label object is a CEikLabel object.
In order to set the text label, in the construct method of your container you can use the SetText() method.
It works fine. But, if at the beginning you set a null text (for example, the empty literal _L("") ) you may run into a drawback: if you wish call SetText() for a second time (for example, for changing the displayed text), the text didn't change at all : for ever the label will display the empty text label :-( !

To avoid that, I have discovered a simple trick : write the first SetText() call in your construct method (ConstructL()) as follow:

_LIT(KManySpacesStr," ");
myLabel->SetText(KManySpacesStr);

Add spaces into KManySpacesStr to reach the expected maximum label text lenght.

Nessun commento: