×
Namespaces

Variants
Actions
(Difference between revisions)

How to create Label

From Nokia Developer Wiki
Jump to: navigation, search
kiran10182 (Talk | contribs)
m (different names)
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Add ArticleMetaData)
Line 1: Line 1:
<div align="right">'''Reviewer Approved''' &nbsp;&nbsp; [[File:Thumbs_up_icon_sm.jpg|31x38px]]</div>
+
{{ArticleMetaData <!-- v1.2 -->
Following code snippet shows how to create Label control in [[Symbian C++]].
+
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 +
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Qt SDK 1.1.4]) -->
 +
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 +
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20080627
 +
|author= [[User:Kiran10182]]
 +
}}
 +
<div align="right">'''Reviewer Approved''' &nbsp;&nbsp; [[File:Thumbs up icon sm.jpg|31x38px]]</div>
 +
Following code snippet shows how to create Label control in [[:Category:Symbian C++|Symbian C++]].
  
 
== Step 1: LabelTestAppView.h ==
 
== Step 1: LabelTestAppView.h ==
Line 88: Line 110:
 
----
 
----
 
[[Category:Symbian C++]]
 
[[Category:Symbian C++]]
[[Category:Code Examples]]
+
[[Category:Code Snippet]]
 
[[Category:UI]]
 
[[Category:UI]]
 
[[Category:How To]]
 
[[Category:How To]]

Revision as of 05:36, 26 July 2012

Article Metadata
Article
Created: kiran10182 (27 Jun 2008)
Last edited: hamishwillee (26 Jul 2012)
Reviewer Approved    Thumbs up icon sm.jpg

Following code snippet shows how to create Label control in Symbian C++.

Step 1: LabelTestAppView.h

  • Open your LabelTestAppView.h file.
  • Include entries for required header files.
#include <eiklabel.h>
  • Add required functions which will be needed for control.
TInt CountComponentControls() const;
CCoeControl* ComponentControl(TInt aIndex) const;
void PutTextL(const TDesC& aText); // To change text(user-inputted)
  • Declare object of Label:
private: // data
// ..
CEikLabel* iLabel;

Step 2: LabelTestAppView.cpp

  • Open your "LabelTestAppView.cpp" file.
  • Now in the ContructL() function of your LabelTestAppView.cpp file:
void CLabelTestAppView::ConstructL( const TRect& aRect )
{
// Create a window for this application view
CreateWindowL();
 
_LIT(KTextHelloWorld, "hello world");
iLabel = new (ELeave) CEikLabel;
iLabel->SetContainerWindowL( *this );
iLabel->SetTextL(KTextHelloWorld);
 
// Set the windows size
SetRect( aRect );
 
// Activate the window, which makes it ready to be drawn
ActivateL();
}
 
CLabelTestAppView::~CLabelTestAppView()
{
delete iLabel;
}
 
void CLabelTestAppView::SizeChanged()
{
iLabel->SetExtent( TPoint(0,0), iLabel->MinimumSize());
}
 
TInt CLabelTestAppView::CountComponentControls() const
{
return 1;
}
 
CCoeControl* CLabelTestAppView::ComponentControl(TInt aIndex) const
{
switch ( aIndex )
{
case 0:
return iLabel;
default:
return NULL;
}
}
 
//Call this function to change value of Label
void CLabelTestAppView::PutTextL(const TDesC& aText)
{
iLabel->SetTextL(aText);
}

Note: Do not forget to add an entry for eikcoctl.lib in your .mmp file.


65 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×