Inner Class members

Hi,
I have some of Qstring type members in my inner class like the following;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
	class GmailProfile : public QObject
	{
		public:

			GmailProfile();
			~GmailProfile();

			QString getGmailName();
			void setGmailName(QString&);
			QString getGmailSurName();
			void setGmailSurName(const QString&);
			QString getGmailDisplayName();
			void setGmailDisplayName(const QString&);
			QString getGmailUri();
			void setGmailUri(const QString&);
			QString getGmailEmail();
			void setGmailEmail(const QString&);
			QString getGmailStatus();
			void setGmailStatus(const QString&);
			QPixmap getAvatar(const QSize& size=QSize());
			void setAvatar(QPixmap avatar);

		public:

			QString _gmailName;
			QString _gmailSurname;
			std::string _gmailDisplayName;
			QString _gmailUri; // same as att. uri
			QString _gmailEmail;
			QString _gmailStatus;
			QPixmap _gmail_avatar;

	};


Problem is when I dynamicly created GmailProfile inner class, members don't created.

Any ideas?
What does it mean "members don't created"
How do you create the GmailProfile object?
Yes I do of course,

Sorry for the wrong use coder777, I mean I take "expression cannot be evaluated" error in runtime when I want to access those members in the code above.
I created it in the constructor of it's enlosing class called Contact.
Last edited on
It has nothing to do with the members. It has to do with how you access the GmailProfile object. Show the code where the error actually occur
Here where I created Gmail Profile;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Contact::Contact(const QString& username, const QString& domain, QObject* parent) { 
    Contact::Contact(parent);
    setUsername(username);
    setDomain(domain);
    QString uri = username + "@" + domain;
    setUri(uri);
    setContactIdentifier(uri);
	_isMSNContact = false;
	_isGmailContact = false;
	this->_gmailProfile = new Contact::GmailProfile();
	this->_MSNProfile = new Contact::MSNProfile();
	_gmailProfile->setParent(this); // to delete gmail profile object when corresponsing contact is deleted
	_MSNProfile->setParent(this); // to delete MSN profile object when corresponsing contact is deleted
}


And this is Where the error occurs;

1
2
3
4
5
const QString& Contact::getDisplayName() {

	if(getGmailProfile()->getGmailDisplayName().isEmpty())
				{ }


and the code of method is;

1
2
3
4
5
QString Contact::GmailProfile::getGmailDisplayName()
{
	return _gmailDisplayName;
}


An error says; Expression cannot be evaluated!
Last edited on
I don't understand your error. You say you get it at runtime?

I don't know if it's relevant but Contact::Contact(parent); creates a temporary Contact object that will only exist on that line (2).

Can std::string be implicit converted to a QString? Maybe you have to write return QString::fromStdString(_gmailDisplayName); I have never used Qt so I don't really know.
It's not a matter of Qt I suppose. I guess I'm violating access issues as coder777 suggested.
Contact::getDisplayName() returns const QString&. But in that function there's an if that usually doesn't work well together.

I would have expected that Contact::getDisplayName() returns QString and Contact::GmailProfile::getGmailDisplayName() returns const QString&
Ok but how did you relate this with "Expression cannot be evaluated" error?
Can you give us a copy paste of where the error is being stated?

You are leaving code out that might be relevant, this wont compile, there is no closing bracket, nothing is returned... so since this isn't the 'real' code I cant determine what expression it is talking about...
1
2
3
4
const QString& Contact::getDisplayName() {

	if(getGmailProfile()->getGmailDisplayName().isEmpty())
				{ }


As coder777 has pointed out, you are returning a temporary QString and then returning a reference to this temporary (which will be destroyed before you even use it), granted this isn't your stated problem but this is a problem.
Last edited on
Topic archived. No new replies allowed.