steg90
24th May 2007, 09:35
Hi,
I have a QMultiHash object which stores objects key'd on QString. At the time, this seemed a good solution to a problem I had, now it looks like it has come back to bite me.
Here is the object that gets stored in this map :
class ASignal
{
public:
ASignal() { }
char m_name[256];
char m_unit[256];
double m_dmaximum;
double m_dminimum;
double m_dfactor;
double m_doffset;
UINT m_istartbit;
UINT m_ilength;
double m_realvalue;
long m_rawvalue;
double m_byteorder;
};
class CSignal : public ASignal
{
public:
CString m_strRawData;
CString m_strId; // Can ID
char m_canname[256]; // Can user friendly name
int m_nCount;
};
So, my map will contain QString's which can be the same and have the object associated with it as shown above. My problem is, how can I remove one of these objects from the QMultiHash map without removing all objects with the same key??
The code below, would remove ALL my objects with the same key, I don't suppose there is a way of removing the object from the map without removing other objects that are key'd on the same QString value without having to change my structures and use a QHash instead of the QMultiHash?
m_oSignalMap.remove( iter.key() );
Hope this makes sense?
Regards,
Steve
I have a QMultiHash object which stores objects key'd on QString. At the time, this seemed a good solution to a problem I had, now it looks like it has come back to bite me.
Here is the object that gets stored in this map :
class ASignal
{
public:
ASignal() { }
char m_name[256];
char m_unit[256];
double m_dmaximum;
double m_dminimum;
double m_dfactor;
double m_doffset;
UINT m_istartbit;
UINT m_ilength;
double m_realvalue;
long m_rawvalue;
double m_byteorder;
};
class CSignal : public ASignal
{
public:
CString m_strRawData;
CString m_strId; // Can ID
char m_canname[256]; // Can user friendly name
int m_nCount;
};
So, my map will contain QString's which can be the same and have the object associated with it as shown above. My problem is, how can I remove one of these objects from the QMultiHash map without removing all objects with the same key??
The code below, would remove ALL my objects with the same key, I don't suppose there is a way of removing the object from the map without removing other objects that are key'd on the same QString value without having to change my structures and use a QHash instead of the QMultiHash?
m_oSignalMap.remove( iter.key() );
Hope this makes sense?
Regards,
Steve