Results 1 to 6 of 6

Thread: object to string

  1. #1
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default object to string

    hi
    i have a function which returns object ,i need to display the object name ,ie. store the object name in qstring ,how to do it.

  2. #2
    Join Date
    Oct 2007
    Location
    Munich, Bavaria
    Posts
    144
    Thanks
    1
    Thanked 19 Times in 19 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: object to string

    is this what you are looking for?
    http://doc.trolltech.com/4.3/qobject...bjectName-prop

  3. #3
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default Re: object to string

    thanks u.........

    assume there are two classes CLASSA and CLASSB.
    object of CLASSA is OBJA.
    object of CLASSB is OBJB.

    now
    CLASSA contains function FA()(return type of FA()is QString) which returns(OBJA.FA()) the name of object(ie.QString("OBJB"))

    how to convert this string to object.
    Last edited by babu198649; 30th January 2008 at 11:20.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: object to string

    Could you rephrase what do you intend to do? In first post said "object to string" but now you say "string to object".
    J-P Nurmi

  5. #5
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default Re: object to string

    hi
    In first post said "object to string" but now you say "string to object".
    i meant to get the name of the object by having its address. but as there is no name at run time for an object(please correct me if i am wrong).
    i went to the second method where a string is converted to objects name. sorry for the different set of questions.


    i have a label which on clicked an object should be created such that the name of the object should be the name of the labels text.

  6. #6
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: object to string

    If the object you create is a QObject then you can use
    Qt Code:
    1. obj->setObjectName(label->text());
    To copy to clipboard, switch view to plain text mode 
    Later, you can get the object's name with obj->objectName().

  7. The following user says thank you to marcel for this useful post:

    babu198649 (2nd June 2008)

Similar Threads

  1. Getting std::string object from QString object ( qt3)
    By joseph in forum Qt Programming
    Replies: 11
    Last Post: 28th March 2013, 20:09
  2. Reading from sockets in a multithreaded program
    By KoosKoets in forum Qt Programming
    Replies: 9
    Last Post: 4th April 2007, 20:43
  3. saving a c string of variable length in a shared memory?
    By nass in forum General Programming
    Replies: 4
    Last Post: 3rd January 2007, 14:40
  4. Create pixmap image from string
    By Morea in forum Qt Programming
    Replies: 5
    Last Post: 17th November 2006, 16:38
  5. signal slot conection using a string, not a SLOT
    By rianquinn in forum Qt Programming
    Replies: 6
    Last Post: 5th February 2006, 18:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.