PDA

View Full Version : QMultiHash



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

wysota
24th May 2007, 09:44
Qt 4.3 has a method to remove one of the values from a multi hash.

steg90
24th May 2007, 09:49
Thanks,

Currently evaluating 4.2.3, guess I will need to download 4.3? What is the name of the method? :rolleyes:

Kind regards,
Steve

wysota
24th May 2007, 09:55
http://doc.trolltech.com/4.3/qmultihash.html#remove

steg90
24th May 2007, 09:59
Many thanks again :D

wysota
24th May 2007, 12:42
No problem.