Results 1 to 2 of 2

Thread: how can i destruct QHash<QString, QPixmap>?

  1. #1
    Join Date
    Aug 2008
    Posts
    11
    Thanks
    1

    Default how can i destruct QHash<QString, QPixmap>?

    hi, all, I use i memeber QHash<QString,QPixmap> in my class ,but when the object is destructed ,it wrong,how can i destruct it.

    class CommElement
    {
    public:
    CommElement()
    {

    }
    ~CommElement()
    {
    //qDeleteAll(m_picManager);
    //m_picManager.clear();

    }

    void loadPictures(QDataStream &s) //return the picture path which have been handle
    {
    s>>m_picManager;
    }

    QHash<QString,QPixmap> pictureManager()
    {
    return m_picManager;
    }

    private:
    QHash<QString,QPixmap> m_picManager;
    };

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how can i destruct QHash<QString, QPixmap>?

    For QHash<QString,QPixmap> you wont need to delete the object since it will get created on stack.
    if you had pointers in ur map , something like QHash<QString,QPixmap*> , then you would need to delete them using qDeleteAll()

Similar Threads

  1. QHash<QString, QVarant> to file
    By weaver4 in forum Newbie
    Replies: 2
    Last Post: 9th February 2010, 06:54
  2. How does QString::qHash() work?
    By Morea in forum Qt Programming
    Replies: 4
    Last Post: 7th September 2009, 09:17
  3. QDataStream and QHash<QString,QVariant> crash on read
    By ^NyAw^ in forum Qt Programming
    Replies: 1
    Last Post: 15th July 2008, 12:14
  4. Can QHash::capacity() be smaller than QHash::size()?!?
    By iw2nhl in forum Qt Programming
    Replies: 2
    Last Post: 24th August 2007, 01:17
  5. paintEvent, QString to QPixmap, QLabel
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 5th February 2007, 13:04

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.