Results 1 to 5 of 5

Thread: Copy a QMap

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2013
    Posts
    50
    Thanks
    5

    Default Copy a QMap

    Hello, I am having problems copying one QMap to another, any help would be appreciated.

    This is my code (where the copying should occur):

    PS. I have solved the issue, seems I just had to add i++ to the code below; Just one question, it seems
    the data is added in the reverse order to the Qmap. For example, when I added "param1","test1"
    key value pair to the QMap as in the end of this post, and also "param2", "test2" ... they are read in an reverse
    order in the loop below. Is it supposed to be like this?? I want the data to be added in the
    same order as I added in the code in the end.. Thanks.

    Qt Code:
    1. bool MyNetworkClass::initializeRequestParam(QMap<QString, QString> params)
    2. {
    3. QMap<QString, QString>::const_iterator i = params.constBegin();
    4. while (i != params.constEnd()) {
    5. requestParameters.insert(i.key(), i.value());
    6. i++; // added
    7. }
    8.  
    9. return true; // this is default...
    10. }
    To copy to clipboard, switch view to plain text mode 

    where
    Qt Code:
    1. requestParameters
    To copy to clipboard, switch view to plain text mode 
    is member variable:
    Qt Code:
    1. QMap<QString, QString> requestParameters;
    To copy to clipboard, switch view to plain text mode 

    Now, when I try to issue the above function:

    Qt Code:
    1. MyNetworkClass *p = new MyNetworkClass();
    2.  
    3.  
    4. QMap<QString, QString> params;
    5.  
    6. params.insert("param1", "test1");
    7. params.insert("param2", "test2");
    8. params.insert("param3", "test3");
    9.  
    10. p->initializeRequestParam(params);
    To copy to clipboard, switch view to plain text mode 

    The last line "initializeRequestParam" - seems to not work.. I think it gets in an endless loop...
    when I debugged into it, I think it managed to successfully copy only one "param1", "test1" pair to the
    Qt Code:
    1. reqestParameters
    To copy to clipboard, switch view to plain text mode 
    destination...
    Any help greatly appreciated as to how to make this function initializeRequestParam work?? and copy one QMap into another..???
    Last edited by ggdev001; 12th February 2013 at 13:18.

Similar Threads

  1. Replies: 1
    Last Post: 27th December 2012, 07:01
  2. QSettings: copy from ini to xml? Copy group?
    By TorAn in forum Qt Programming
    Replies: 1
    Last Post: 11th January 2012, 15:51
  3. QMap
    By sophister in forum Qt Programming
    Replies: 5
    Last Post: 25th May 2009, 11:05
  4. Qmap
    By phillip_Qt in forum Qt Programming
    Replies: 3
    Last Post: 23rd November 2007, 11:43
  5. Reg - QMap(Qt3.3.4)
    By suresh in forum Newbie
    Replies: 3
    Last Post: 18th October 2006, 23: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
  •  
Qt is a trademark of The Qt Company.