I have a class member of type QStringList
. I had a guess that when this class is instantiated, nex
instance get such a QStringLsit
with no elements in it.
I have a function that should fill in this QStringList
on user interaction. However, I see with debugger that class member does not exist at function call. What could it be all about? Is there a way to initialize the QListString
that I may be missing here?
Asked
Active
Viewed 8,184 times
0
-
Is this function a class member? When do you call it? Show some code. – jrok May 22 '12 at 11:46
-
It's impossible that a "class member doesn't exist". Also, if you don't use a pointer for the member (which you shouldn't), the member will be default-constructed, which results in an empty QStringList. – Frank Osterfeld May 22 '12 at 11:49
-
Can you please clarify the question and show the code that you believe is not working correctly? – Component 10 May 22 '12 at 11:51
1 Answers
1
QStringList
should get initialized on the creation of your object automatically (unless it is a pointer). I see two possible explanations for the debugger's behaviour:
- Your object (of which you call the function) doesn't get created before the function call; that means that the
this
pointer is invalid when the function gets entered. This may be the case if you call the function on an uninitialised pointer to your class. - The debugger just doesn't show the
QStringList
member correctly. - If your member is of type
QStringList*
(a pointer), it doesn't get automatically initialised on object creation. Then you'd need to dolist = new QStringList();
in the constructor. But I doubt that you need a pointer to a string list here.

leemes
- 44,967
- 21
- 135
- 183