[Qt-interest] QStringListModel setStringList usage

Francisco Gonzalez gzmorell at gmail.com
Thu Dec 23 00:55:03 CET 2010


Thanks to all, and sorry for that basic error that I have not seen.

2010/12/22 Andre Somers <andre at familiesomers.nl>:
> Op Wo, 22 december, 2010 10:11 am, schreef J-P Nurmi:
>> On Wed, Dec 22, 2010 at 10:02 AM, Francisco Gonzalez <gzmorell at gmail.com>
>> wrote:
>>>        QStringListModel *myModel = new QStringListModel();
>>
>> You want to assign to the member variable, not to a local variable,
>> right? So it should be:
>>
>> myModel = new QStringListModel();
>>
> To clarify J-P's answer:
>
> QStringListModel* myModel = new ... declares a new local variable myModel,
> that then hides the member variable with the same name. That means that no
> value is assigned to the member variable myModel, which is referenced by
> your check() function.
>
> Personally, I use a prefix m_ for the names of membervariables. That makes
> them easy to spot (and s_ for statics, and g_ for globals). Those can be
> assigned, but never declared inside a member function.
>
> André
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>



More information about the Qt-interest-old mailing list