I don’t have much experience with Qt but somehow I think this is acting strange.
Compiled with VS2005:
class Entry
{
public:
Entry(const QString& aName, bool checked) :
name(aName), isChecked(checked)
{
// empty
};
Entry(const Entry& entry) :
name(entry.name), isChecked(entry.isChecked)
{
// empty
};
Entry& operator=(const Entry& entry)
{
name = entry.name;
isChecked = entry.isChecked;
return *this;
}
QString name;
bool isChecked;
};
typedef QList<conduit::Entry> EntryVector;
When using EntryVector in the following lines, the entry in QList becomes a bad pointer:
void EntryWidget::setEntries(QStringList& names)
{
QStringList::iterator member;
EntryVector list;
for (member = names.begin(); member != names.end(); ++member)
{
Entry entry(*member, false);
list.append(entry);
}
m_model.setEntryData(list);
}
Somehow, entry.name in the list will become a bad pointer. My understanding is that QList should be able to support any data in its template, but for some reason that I yet do not understand this does not work. Everything works just fine if I use a STL Vector.
Any ideas? Thanks
I had this same problem, and came looking for anwsers.
I though my code was misbehaving, when it’s not.
VS2005 debugger doesn’t show you the things in QList correctly.
And as davmac suggested, when you print the stuff out, it works fine.
And davmac, please don’t point out that he might have a memory corruption when the guy gives you a piece of code to try. If you can’t try it with the same setup, that’s another thing.