[Qt-interest] QStringListModel setStringList usage
Andre Somers
andre at familiesomers.nl
Wed Dec 22 10:19:32 CET 2010
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é
More information about the Qt-interest-old
mailing list