Results 1 to 3 of 3

Thread: QHash

  1. #1
    Join Date
    Oct 2007
    Posts
    78
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QHash

    Is there a special way to manipulate a QDomElement so I can use it as an index in a QHash?

    Qt Code:
    1. QHash<QDomElement, QTreeWidgetItem *> itemFromElement;
    To copy to clipboard, switch view to plain text mode 

    Chokes with no candidates. In the docs I see a qHash ( const T * key ) but it escapes me how to make QDomElement work in this case.

    Bob

  2. #2
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QHash

    You must provide a function "qHash ( const QDomElement * key )" and return a proper value for each DomElement.

  3. #3
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QHash

    Qt Code:
    1. QHash<QDomElement, QTreeWidgetItem *> itemFromElement;
    To copy to clipboard, switch view to plain text mode 
    Well, a QDomElement is no pointer, so that does not help you here. (This function just means that you can hash any pointer types.)

    If you want to hash QDomElements (do you really need to?), you must provide a function
    Qt Code:
    1. uint qHash(const QDomElement&);
    To copy to clipboard, switch view to plain text mode 

    A possible (not nec. good) way would be to transform all the relevant stuff of a QDomElement into a QString and hash that.

    I suggest to think hard about if you really need/want to hash QDomElements.
    Tell us why you want to do it. Perhaps we find a different solution.

    HTH

Similar Threads

  1. QHash ordered by value
    By Lele in forum Qt Programming
    Replies: 7
    Last Post: 11th February 2008, 09:30
  2. QHash static member error
    By ramazangirgin in forum Qt Programming
    Replies: 7
    Last Post: 5th February 2008, 11:26
  3. QHash with 2 keys?
    By MrGarbage in forum Qt Programming
    Replies: 5
    Last Post: 6th September 2007, 01:09
  4. signals and slots with container types like QHash
    By themolecule in forum Qt Programming
    Replies: 3
    Last Post: 28th August 2007, 08:07
  5. QHash compile error
    By jiveaxe in forum Qt Programming
    Replies: 10
    Last Post: 27th August 2007, 13:58

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.