Results 1 to 3 of 3

Thread: [solved] Qmap and pointer issue

  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default [solved] Qmap and pointer issue

    Hi,

    I use a pointer to a QMap<int, QStringList> and need to change the QStringList, but
    Qt Code:
    1. m_currentAskedVocBox = 0;
    2. QMap<int, QStringList> *box = (m_currentAskedVocType == lectionSystem::Box) ? &m_boxBox : &m_boxLection;
    3. box[m_currentAskedVocBox+1] << box[m_currentAskedVocBox].takeFirst();
    To copy to clipboard, switch view to plain text mode 
    throws the error: »class QMap<int, QStringList>« has no element called »takeFirst«.

    Seems the compiler does not like the []operator. But how to get a reference on an other way? Unfortunately QMap has no at().

    Or my be there ist a way to tell the compiler that "box[]" is a QStringList. casts?

    Thanks,

    Lykurg

    *edit* dereference! (*box)[] works.
    Last edited by Lykurg; 22nd September 2007 at 12:23.

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

    Default Re: [solved] Qmap and pointer issue

    Using QMap::begin() is also an option

  3. #3
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: [solved] Qmap and pointer issue

    Try
    Qt Code:
    1. QMap<int, QStringList>& box = (m_currentAskedVocType == lectionSystem::Box) ? m_boxBox : m_boxLection;
    2. box[m_currentAskedVocBox+1] << box[m_currentAskedVocBox].takeFirst();
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QMap Problem with arguments.
    By ankurjain in forum Qt Programming
    Replies: 1
    Last Post: 24th May 2006, 12:12
  2. Is there a Pointer Based QMap or Similar
    By vasudhamirji in forum Qt Programming
    Replies: 3
    Last Post: 4th April 2006, 14:34

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.