Results 1 to 6 of 6

Thread: QMultiHash

  1. #1
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QMultiHash

    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 :

    Qt Code:
    1. class ASignal
    2. {
    3. public:
    4. ASignal() { }
    5. char m_name[256];
    6. char m_unit[256];
    7. double m_dmaximum;
    8. double m_dminimum;
    9. double m_dfactor;
    10. double m_doffset;
    11. UINT m_istartbit;
    12. UINT m_ilength;
    13. double m_realvalue;
    14. long m_rawvalue;
    15. double m_byteorder;
    16. };
    17.  
    18. class CSignal : public ASignal
    19. {
    20. public:
    21. CString m_strRawData;
    22. CString m_strId; // Can ID
    23. char m_canname[256]; // Can user friendly name
    24. int m_nCount;
    25. };
    To copy to clipboard, switch view to plain text mode 

    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?

    Qt Code:
    1. m_oSignalMap.remove( iter.key() );
    To copy to clipboard, switch view to plain text mode 

    Hope this makes sense?

    Regards,
    Steve

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QMultiHash

    Qt 4.3 has a method to remove one of the values from a multi hash.

  3. #3
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QMultiHash

    Thanks,

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

    Kind regards,
    Steve

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

  5. #5
    Join Date
    May 2007
    Posts
    301
    Thanks
    46
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QMultiHash

    Many thanks again

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QMultiHash

    No problem.

Similar Threads

  1. QMultiHash - crashing
    By steg90 in forum Qt Programming
    Replies: 16
    Last Post: 23rd May 2007, 13:18

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.