PDA

View Full Version : [solved] Qmap and pointer issue



Lykurg
22nd September 2007, 12:03
Hi,

I use a pointer to a QMap<int, QStringList> and need to change the QStringList, but

m_currentAskedVocBox = 0;
QMap<int, QStringList> *box = (m_currentAskedVocType == lectionSystem::Box) ? &m_boxBox : &m_boxLection;
box[m_currentAskedVocBox+1] << box[m_currentAskedVocBox].takeFirst();
throws the error: »class QMap<int, QStringList>« has no element called »takeFirst«.

Seems the compiler does not like the []operator. But how to get a reference on an other way? Unfortunately QMap has no at().

Or my be there ist a way to tell the compiler that "box[]" is a QStringList. casts?

Thanks,

Lykurg

*edit* dereference! (*box)[] works. :o

wysota
25th September 2007, 12:51
Using QMap::begin() is also an option :)

spud
26th September 2007, 15:34
Try


QMap<int, QStringList>& box = (m_currentAskedVocType == lectionSystem::Box) ? m_boxBox : m_boxLection;
box[m_currentAskedVocBox+1] << box[m_currentAskedVocBox].takeFirst();