Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 19

Thread: Labels

  1. #1
    Registered User zohirey2's Avatar
    Join Date
    Nov 2008
    Location
    Cairo-Egypt
    Posts
    80
    here my application is GUI with UI designer

    i put a lable in the form
    and its name is label1

    and in handling a menu option command i write this code


    label1->SetText(_L("Mohamed Is in Love and Not!!"));

    but compiler give me this error


    undefined identifier 'label1'
    what is the problem?

  2. #2
    Nokia Developer Champion kiran10182's Avatar
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,236
    Quote Originally Posted by zohirey2 View Post
    undefined identifier 'label1'
    what is the problem?
    Problem lies in your description itself. Make sure that label1 is defined in the context you are trying to use.
    Nokia Developer Wiki Moderation team

  3. #3
    Registered User zohirey2's Avatar
    Join Date
    Nov 2008
    Location
    Cairo-Egypt
    Posts
    80
    OK i am sure of this
    but how can i solve it

  4. #4
    Nokia Developer Champion kiran10182's Avatar
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,236
    Quote Originally Posted by zohirey2 View Post
    OK i am sure of this
    but how can i solve it
    But complier is aways right, generally. It says that label1 is undefined and so it would be. Can you show where did you declare label1 in your code?
    Nokia Developer Wiki Moderation team

  5. #5
    Super Contributor tamhanna's Avatar
    Join Date
    Jul 2008
    Posts
    2,020
    Did you define label1 where? Just in Carbide.ui?

    We need more info. In what context is this call?
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  6. #6
    Registered User zohirey2's Avatar
    Join Date
    Nov 2008
    Location
    Cairo-Egypt
    Posts
    80
    i haven't declare label1 any where!
    i am sorry i forget to mention this
    where i have to declare it

  7. #7
    Registered User stavrospapa's Avatar
    Join Date
    Sep 2008
    Posts
    144
    hi!

    if you have used the GUI to place a label,
    then search in class your_appContainer.cpp
    (the variable should be iLabel1)

    If you have used the options menu to change the label's text,
    then you need to define a new method (i.e., changeText())
    in your_appContainer.cpp to be called by your_appContainerView.cpp
    at the event handler method.

    hope that helps!
    Stavros

  8. #8
    Registered User zohirey2's Avatar
    Join Date
    Nov 2008
    Location
    Cairo-Egypt
    Posts
    80
    Quote Originally Posted by tamhanna View Post
    Did you define label1 where? Just in Carbide.ui?

    We need more info. In what context is this call?



    i have make a method
    called
    void ChangeText();
    and put it in applicationContainer.h
    and make the following defination in applicationContainer.cpp

    void ChangeText(const TRect& aRect)
    {
    label1->SetTextL(aRect);

    }
    in applicationVontainerView


    _LIT(x,"Mohamed is not happy");
    label1->ChangeText(x);

    but it tell me that
    label1 is undefined

    i try instate of label1 using iLabel1

    but i face the same problem

  9. #9
    Nokia Developer Moderator wizard_hu_'s Avatar
    Join Date
    Feb 2006
    Location
    Mallorca, Holiday
    Posts
    27,683
    May I ask why you think that 'label1' should exist?
    It is not even clear if you are really talking about a form (CAknForm, lines containing heading and some kind of editor) or an empty page.
    Have you considered reading the code prior to modifying it? If you check the header file for the view/container, and search for the word label in it, you will quickly find if there is a label at all, and if it exists, you will find its name.

  10. #10
    Nokia Developer Champion savaj's Avatar
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034
    Quote Originally Posted by zohirey2 View Post
    i have make a method
    called
    void ChangeText();
    and put it in applicationContainer.h
    and make the following defination in applicationContainer.cpp

    void ChangeText(const TRect& aRect)
    {
    label1->SetTextL(aRect);

    }
    in applicationVontainerView


    _LIT(x,"Mohamed is not happy");
    label1->ChangeText(x);

    but it tell me that
    label1 is undefined

    i try instate of label1 using iLabel1

    but i face the same problem

    Have you declared label1 in your applicationContainer.h ??? Do you know the meaning of TRect ??? Even if you declare and instantiate label1 the statement "label1->SetTextL(aRect)" will not compile.

    I suggest you to once go through following article to create label in your container.
    http://wiki.forum.nokia.com/index.ph...o_create_Label

  11. #11
    Registered User zohirey2's Avatar
    Join Date
    Nov 2008
    Location
    Cairo-Egypt
    Posts
    80
    Quote Originally Posted by savaj View Post
    Have you declared label1 in your applicationContainer.h ??? Do you know the meaning of TRect ??? Even if you declare and instantiate label1 the statement "label1->SetTextL(aRect)" will not compile.

    I suggest you to once go through following article to create label in your container.
    http://wiki.forum.nokia.com/index.ph...o_create_Label
    very good
    but i am using UI Designer
    i mean that i place a label from tool box
    where should i declare it

  12. #12
    Nokia Developer Champion kiran10182's Avatar
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,236
    Quote Originally Posted by zohirey2 View Post
    very good
    but i am using UI Designer
    i mean that i place a label from tool box
    where should i declare it
    When you drag-drop controls(label) from UI designer, it will show as lable1, label2 etc... When you save the UI design, Carbide.c++ IDE will add iLabel1 in your *Container.h and *Container.cpp files.

    So you need to play with iLabel1 instead of label1. Try with adding one more label from UI designer and after saving it see the corresponding changes in your *Container.h/cpp files.

    Code:
    void ChangeText(const TDesC& aText) //Because you need to pass text, not Rect, ideally
    {
         iLabel1->SetTextL(aText);
    
    }
    I hope this helps.
    Nokia Developer Wiki Moderation team

  13. #13
    Registered User zohirey2's Avatar
    Join Date
    Nov 2008
    Location
    Cairo-Egypt
    Posts
    80
    Quote Originally Posted by kiran10182 View Post
    When you drag-drop controls(label) from UI designer, it will show as lable1, label2 etc... When you save the UI design, Carbide.c++ IDE will add iLabel1 in your *Container.h and *Container.cpp files.

    So you need to play with iLabel1 instead of label1. Try with adding one more label from UI designer and after saving it see the corresponding changes in your *Container.h/cpp files.

    Code:
    void ChangeText(const TDesC& aText) //Because you need to pass text, not Rect, ideally
    {
         iLabel1->SetTextL(aText);
    
    }
    I hope this helps.


    thank you so much
    you understand me very good
    but
    let me want to change the text of label in selecting the first choice of options
    do i need to implement the function SetText()
    and if so
    where to declare it .h
    and how to call it in the event

    i am sorry for being stupid a lot!

  14. #14
    Nokia Developer Champion savaj's Avatar
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034
    Quote Originally Posted by zohirey2 View Post
    thank you so much
    you understand me very good
    but
    let me want to change the text of label in selecting the first choice of options
    do i need to implement the function SetText()
    and if so
    where to declare it .h
    and how to call it in the event

    i am sorry for being stupid a lot!
    1) declare/define function (say ChangeText()) in container.
    2) declare/define function (say ChangeText()) in containerview (if you have).
    3) call ContainerView::ChangeText() from Appui::HandleCommandL()
    4) call Container::ChangeText() from ContainerView::ChangeText()
    4) set text in your label in Container::ChangeText()

    Hope this will help you.

  15. #15
    Nokia Developer Champion kiran10182's Avatar
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,236
    Quote Originally Posted by savaj View Post
    1) declare/define function (say ChangeText()) in container.
    2) declare/define function (say ChangeText()) in containerview (if you have).
    3) call ContainerView::ChangeText() from Appui::HandleCommandL()
    4) call Container::ChangeText() from ContainerView::ChangeText()
    4) set text in your label in Container::ChangeText()

    Hope this will help you.
    To avoid these, people are using Carbide.c++ with UI Designer. It is a matter of drag and drop.

    @zohirey2: You can add menu options from UI designer itself. Go to UI designer and under Label control, you will find Menu->Menu bar. Drag and drop that menu bar on the screen and add whatever option command you want. Say Change Label. It will generate corresponding entries in your application.

    Then in your AppUI class -> Under HandleCommandL function, add following code:

    Code:
    void CUIDesignerTestAppUi::HandleCommandL( TInt aCommand )
    {
    ...
    ....
    ...
    ....
      if ( !commandHandled ) 
      {
    	switch ( aCommand )
    	{ 
    	case EUIDesignerTestAppUiChange_LabelMenuItemCommand: // This is from .hrh file.
    	iUIDesignerTestContainer->ChangeTextL(_L("Hi there"));
                    break;
    	default:
    		break;
    	}
      }
    }
    PS: There might be an easier way than this which I am unaware of.
    Nokia Developer Wiki Moderation team

Page 1 of 2 12 LastLast

Similar Threads

  1. Labels dont refresh
    By slayv in forum Symbian User Interface
    Replies: 2
    Last Post: 2009-03-19, 11:50
  2. Wider tab labels possible?
    By carknue in forum Python
    Replies: 1
    Last Post: 2008-06-29, 16:48
  3. softkeys labels not visible
    By huami in forum Symbian User Interface
    Replies: 2
    Last Post: 2007-06-13, 20:54
  4. Dynamically Changing Softkey Labels
    By srigans1 in forum Symbian User Interface
    Replies: 3
    Last Post: 2006-05-23, 08:59
  5. Hide Softkey Labels
    By valentin_da_itiv in forum Symbian User Interface
    Replies: 6
    Last Post: 2004-02-13, 15:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved