This forum has been archived. All content is frozen. Please use KDE Discuss instead.

QString value disappearing.

Tags: fixed fixed fixed
(comma "," separated)
RyanMcCoskrie
Registered Member
Posts
39
Karma
0
OS

QString value disappearing.  Topic is solved

Tue Jun 21, 2011 2:47 am
Can someone please tell me what is going on here?
I have an application that starts by seeking out certain XML files and creating classes that hold their data. I know that the file's contents is read because of the tests that I used, as shown below:
Code: Select all
if(element.hasAttribute("id") == false)
        throw QString(path + " does not contain and id");
else{
        name = element.attribute("id");
        std::cout << "Found: " << name.toUtf8.data << std::endl;
}

This reliably prints out what I want but when I go to access this information later the string is empty.
Could someone please fill me in on what is happening?


RyanMcCoskrie, proud to be a member of KDE forums since 2008-Dec.
User avatar
anda_skoa
KDE Developer
Posts
783
Karma
4
OS

Re: QString value disappearing.

Tue Jun 21, 2011 7:20 pm
Impossible to say without seeing where you are trying to access the string later on.

Could you have to variables with the same name but different scope?

Cheers,
_


anda_skoa, proud to be a member of KDE forums since 2008-Oct.
RyanMcCoskrie
Registered Member
Posts
39
Karma
0
OS

Re: QString value disappearing.

Tue Jun 21, 2011 10:52 pm
I just logged in to announce that. Sorry to everyone who read my OP.
Placed brown-paper bag on head.


RyanMcCoskrie, proud to be a member of KDE forums since 2008-Dec.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot]