views:

50

answers:

1

Hi,

I made a personnal class which inherits QMap:

class CfgMgr : public QMap<QString, CfgSet*> {...}

I'm trying to iterate over all its elements like that:

CfgMgr* m_pDefaults = new CfgMgr;

// .../...

QMapIterator<QString, CfgSet*> ics(*m_pDefaults);
while (ics.hasNext()) {
   // doing my stuff
}

And I get the compile error:

Can't convert parameter 1 from 'CfgMgr' to 'const QMap< Key,T > &' with [ Key=QString, T=CfgSet * ]

I tried with a dynamic_cast:

QMapIterator<QString, CfgSet*> ics(
    *dynamic_cast< QMap<QString,CfgSet*>* >(m_pDefaults)
);

it compiles, but always returns NULL.

What's wrong? How can I solve this?

A: 

Shouldn't it be just:

QMapIterator<QString, CfgSet*> ics(m_pDefaults);

instead of:

QMapIterator<QString, CfgSet*> ics(*m_pDefaults);
Phil Hannent