Results 1 to 4 of 4

Thread: Why changed values in a foreach don't save?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jul 2014
    Posts
    17
    Thanks
    1

    Default Re: Why changed values in a foreach don't save?

    Yes, i do this (stupid) iteration-stuff only for testing ;-)

    Thanks, you give me the solution. Sorry i normaly work with C#. At C# it's not a "copy". okay, i will do it by ref, because i like the 'foreach' ;-)

    PS: what a stumbling block!!!!


    Added after 26 minutes:


    I tried the "&", but i got an error.

    Qt Code:
    1. // int i=-1;
    2. foreach (FileEntry & itmFile, fileList)
    3. {
    4. //i++;
    5. if((tmpType=="alle")||(itmFile.type==tmpType)) //Stimmt Typ?
    6. {
    7. if(itmFile.size+currentSize<maxSize) //Begrenzung noch nicht überschritten?
    8. {
    9. currentSize += itmFile.size;
    10. itmFile.selected=true; //wird ausgewählt
    11. //fileList[i].selected=true;
    12. continue;
    13. }
    14. }
    15. itmFile.selected=false; //wird nicht ausgewählt
    16. //fileList[i].selected=false;
    17. }
    To copy to clipboard, switch view to plain text mode 


    /usr/include/qt5/QtCore/qglobal.h:860: error: invalid initialization of reference of type 'FileEntry&' from expression of type 'const FileEntry'
    for (variable = *_container_.i;; __extension__ ({--_container_.brk; break;}))


    For your information:
    Qt Code:
    1. QList<FileEntry> fileList;
    To copy to clipboard, switch view to plain text mode 
    (no pointer)
    Last edited by cit; 26th July 2014 at 01:25.

Similar Threads

  1. foreach or alike
    By prophet0 in forum Qt Programming
    Replies: 18
    Last Post: 5th January 2012, 18:03
  2. foreach error while compiling
    By smanoj in forum Newbie
    Replies: 4
    Last Post: 24th November 2011, 06:32
  3. lifetime of foreach
    By BalaQT in forum Newbie
    Replies: 4
    Last Post: 4th March 2010, 16:55
  4. Foreach performance
    By jano_alex_es in forum General Programming
    Replies: 2
    Last Post: 17th November 2009, 14:26
  5. SQL changed values stored?
    By jmqt in forum Newbie
    Replies: 1
    Last Post: 15th June 2009, 18:27

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.