Results 1 to 2 of 2

Thread: For loop error

  1. #1
    Join Date
    Aug 2012
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Exclamation For loop error

    hi i'm getting a very funny and frustrating error in QT here is my simple code:

    Qt Code:
    1. for (int i=0; i<=10;i++);
    2. {
    3. qDebug() << i;
    4.  
    5. }
    To copy to clipboard, switch view to plain text mode 

    and my error :
    error: name lookup of 'i' changed for ISO 'for' scoping

    this error happens if i try to use the variable OUTSIDE the for loop but.... u see

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: For loop error

    Remove ";" after loop declaration
    Qt Code:
    1. for (int i=0; i<=10;i++); //<---- remove ";"
    2. {
    3. qDebug() << i;
    4.  
    5. }
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. The following user says thank you to spirit for this useful post:

    silur (24th August 2012)

Similar Threads

  1. how to make this into a loop
    By prophet0 in forum Qt Programming
    Replies: 2
    Last Post: 7th December 2011, 18:14
  2. Replies: 4
    Last Post: 6th August 2011, 02:40
  3. Main loop thread loop communication
    By mcsahin in forum Qt Programming
    Replies: 7
    Last Post: 25th January 2011, 17:31
  4. GLib-ERROR **: Cannot create pipe main loop wake-up
    By chenxuelian in forum Qt Programming
    Replies: 0
    Last Post: 2nd April 2010, 08:18
  5. while loop question..
    By b1 in forum Qt Programming
    Replies: 3
    Last Post: 25th May 2009, 11:48

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.