Results 1 to 6 of 6

Thread: QMap

  1. #1
    Join Date
    Oct 2007
    Posts
    21
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QMap

    hi,
    How to use auto pointer in qmap.
    I tried giving like QMap<qint32, auto_Ptr Name> m_xxx; .But it gives error.

  2. #2
    Join Date
    Sep 2007
    Location
    Szczecin, Poland
    Posts
    153
    Thanks
    7
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QMap

    hi, could you paste error you had?
    and what do you mean by auto pointer? is it QPointer? Or maybe it is some data type not from qt?
    See GrEEn (Graphics Effects Environment)
    http://sourceforge.net/project/platf...roup_id=232746
    a qt-based plugins oriented MDI image processing application(contains also qt plugins like styles & imageformats).

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QMap

    Quote Originally Posted by AnithaRagupathy View Post
    How to use auto pointer in qmap.
    I tried giving like QMap<qint32, auto_Ptr Name> m_xxx; .But it gives error.
    First of all, get used to a habit of pasting errors you get. We are not mind-readers..

    Secondly, "QMap<qint32, auto_Ptr Name>" is not valid C++. Try to be exact what you write because, again, we cannot guess if you actually wrote for example "QMap<qint32, auto_ptr<Name> >". Anyway, in case you mean std::auto_ptr, you cannot use it in containers. There are solutions like "counted_ptr" which can be used in containers.
    J-P Nurmi

  4. #4
    Join Date
    Oct 2007
    Posts
    21
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMap

    I created auto pointer and wanted to use it like this..

    typedef std::auto_ptr<IBaureihe> IBaureihePtr;
    IBaureihePtr create_IBaureihe();
    QMap<qint32, IBaureihePtr>::iterator lIter

    Errors that i get

    d:/Qt/4.3.0/src/corelib/tools/qhash.h: In constructor `QHashNode<int,
    T>::QHashNode(int, const T&) [with T = LaufwegSbFr::IDSOrgaPtr]':
    d:/Qt/4.3.0/src/corelib/tools/qhash.h:93: instantiated from `static void QHash<Key, T>::duplicat
    ode(QHashData::Node*, void*) [with Key = qint32, T = LaufwegSbFr::IDSOrgaPtr]'
    d:/Qt/4.3.0/src/corelib/tools/qhash.h:535: instantiated from `void QHash<Key, T>::detach_helper(
    [with Key = qint32, T = LaufwegSbFr::IDSOrgaPtr]'
    d:/Qt/4.3.0/src/corelib/tools/qhash.h:551: instantiated from `QHash<Key, T>& QHash<Key, T>:per
    or=(const QHash<Key, T>&) [with Key = qint32, T = LaufwegSbFr::IDSOrgaPtr]'
    GlobalLaufwegImpl.cpp:528: instantiated from `void QHash<Key, T>::clear() [with Key = qint32, T
    LaufwegSbFr::IDSOrgaPtr]'
    GlobalLaufwegImpl.cpp:21: instantiated from here
    d:/Qt/4.3.0/src/corelib/tools/qhash.h:215: passing `const
    LaufwegSbFr::IDSOrgaPtr' as `this' argument of `std::auto_ptr<_Tp>:perator
    std::auto_ptr_ref<_Tp1>() [with _Tp1 = LaufwegSbFr::IDSOrga, _Tp =
    LaufwegSbFr::IDSOrga]' discards qualifiers

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMap

    Quote Originally Posted by AnithaRagupathy View Post
    I created auto pointer and wanted to use it like this..

    typedef std::auto_ptr<IBaureihe> IBaureihePtr;
    When auto_ptr is destroyed, it destroys also the object it points to, which makes it completely unsuable for storing in any containers. Use boost::shared_ptr instead.

  6. #6
    Join Date
    Sep 2007
    Location
    Szczecin, Poland
    Posts
    153
    Thanks
    7
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QMap

    Quote Originally Posted by AnithaRagupathy View Post
    typedef std::auto_ptr<IBaureihe> IBaureihePtr;
    IBaureihePtr create_IBaureihe();
    QMap<qint32, IBaureihePtr>::iterator lIter
    You're putting variable name instead of type try with
    Qt Code:
    1. QMap<qint32, std::auto_ptr<IBaureihe> >::iterator lIter
    To copy to clipboard, switch view to plain text mode 
    See GrEEn (Graphics Effects Environment)
    http://sourceforge.net/project/platf...roup_id=232746
    a qt-based plugins oriented MDI image processing application(contains also qt plugins like styles & imageformats).

Similar Threads

  1. Static Init of a QMap
    By Scorp1us in forum Qt Programming
    Replies: 2
    Last Post: 22nd June 2010, 15:08
  2. QMap Problem with arguments.
    By ankurjain in forum Qt Programming
    Replies: 1
    Last Post: 24th May 2006, 12:12
  3. QMap destructor bug
    By Ruud in forum Qt Programming
    Replies: 6
    Last Post: 8th April 2006, 09:08
  4. Is there a Pointer Based QMap or Similar
    By vasudhamirji in forum Qt Programming
    Replies: 3
    Last Post: 4th April 2006, 14:34
  5. Replies: 4
    Last Post: 14th February 2006, 21:35

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.