Results 1 to 4 of 4

Thread: Odd Results in Application Output Pane on simple C++ app

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2013
    Posts
    3

    Default Odd Results in Application Output Pane on simple C++ app

    Running Qt Creator 2.7.0 Based on Qt 5.0.2 (32 bit).


    1. Start Qt, File --> New File or Project --> Non-Qt Project --> Plain C++ Project --> Choose

    Name: t1
    Create in: E:\test\
    Use as default project location: left unchecked

    Hit Next.

    2. Kit Selection

    (checked) Desktop Qt 5.0.2 MinGw 32bit
    (checked) E:\test\build-t1-Desktop_Qt_5_0_2_MinGW_32bit-Debug
    (checked) E:\test\build-t1-Desktop_Qt_5_0_2_MinGW_32bit-Release

    Hit Next.

    3. Project Management

    Add to version control: <None>

    Hit Finish


    4. Select "Projects" button --> Run tab --> Uncheck "Run in terminal"

    5. Edit button. Update main.cpp to the following:

    Qt Code:
    1. #include <iostream>
    2.  
    3. using namespace std;
    4.  
    5. int main()
    6. {
    7. int i;
    8.  
    9. for (i=1; i<52; i++)
    10. {
    11. cout << i << endl;
    12. }
    13. cout << endl;
    14. return 0;
    15. }
    To copy to clipboard, switch view to plain text mode 

    t1.pro file is left to default values:

    Qt Code:
    1. TEMPLATE = app
    2. CONFIG += console
    3. CONFIG -= app_bundle
    4. CONFIG -= qt
    5.  
    6. SOURCES += main.cpp
    To copy to clipboard, switch view to plain text mode 

    6. Hit RUN (Ctrl+R)

    Results (Application Output Pane):

    Qt Code:
    1. Starting E:\test\build-t1-Desktop_Qt_5_0_2_MinGW_32bit-Debug\debug\t1...
    2. 1
    3. 2
    4. 3
    5. 4
    6. 5
    7. 6
    8. 7
    9. 8
    10. 9
    11. 10
    12. 11
    13. 12
    14. 13
    15. 14
    16. 15
    17. 16
    18. 17
    19. 18
    20. 19
    21. 20
    22. 21
    23. 22
    24. 23
    25. 24
    26. 25
    27. 26
    28. 27
    29. 28
    30. 29
    31. 30
    32. 31
    33. 32
    34. E:\test\build-t1-Desktop_Qt_5_0_2_MinGW_32bit-Debug\debug\t1 exited with code 0
    To copy to clipboard, switch view to plain text mode 

    Hit RUN again (Ctrl+r)

    Results (Application Output Pane):

    Qt Code:
    1. Starting E:\test\build-t1-Desktop_Qt_5_0_2_MinGW_32bit-Debug\debug\t1...
    2. 1
    3. E:\test\build-t1-Desktop_Qt_5_0_2_MinGW_32bit-Debug\debug\t1 exited with code 0
    To copy to clipboard, switch view to plain text mode 

    Hit DEBUG (F5)

    Results (Application Output Pane):

    Qt Code:
    1. Debugging starts
    2. 1
    3. 2
    4. 3
    5. 4
    6. 5
    7. 6
    8. 7
    9. 8
    10. 9
    11. 10
    12. 11
    13. 12
    14. 13
    15. 14
    16. 15
    17. 16
    18. 17
    19. 18
    20. 19
    21. 20
    22. 21
    23. 22
    24. 23
    25. 24
    26. 25
    27. 26
    28. 27
    29. 28
    30. 29
    31. 30
    32. 31
    33. 32
    34. 33
    35. 34
    36. 35
    37. 36
    38. 37
    39. 38
    40. 39
    41. 40
    42. 41
    43. 42
    44. 43
    45. 44
    46. 45
    47. 46
    48. 47
    49. 48
    50. 49
    51. 50
    52. 51
    53.  
    54. Debugging has finished
    To copy to clipboard, switch view to plain text mode 

    What the heck is going on here? Every time I run this with "RUN Ctrl+R" I get different results, but I get the expected (and reliable) results in DEBUG (F5)?

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Odd Results in Application Output Pane on simple C++ app

    Not sure what machine you are running it on.

    Its showing proper result with printing till 51 on my machine.. Tried under release and debug builds both.

  3. #3
    Join Date
    Sep 2013
    Posts
    3

    Default Re: Odd Results in Application Output Pane on simple C++ app

    Windows 7 64bit with Intel Xeon E5410.

    As in step 2 above, though I compiled with "Desktop Qt 5.0.2 MinGw 32bit."

  4. #4
    Join Date
    Sep 2013
    Posts
    3

    Default Re: Odd Results in Application Output Pane on simple C++ app

    If I change the code slightly, this appears to work. I'm not sure why, but there must be some kind of glitch with flushing cout on std::endl in Qt Application Panel.
    Qt Code:
    1. #include <iostream>
    2.  
    3. using namespace std;
    4.  
    5. int main()
    6. {
    7. int i;
    8.  
    9. for (i=1; i<52; i++)
    10. {
    11. cout << i << "\n";
    12. }
    13. cout << endl;
    14. return 0;
    15. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Application output pane
    By stef13013 in forum Newbie
    Replies: 2
    Last Post: 30th June 2013, 18:31
  2. Qt Creator Can I post links to code lines in output pane using external tools?
    By mrsomeonee in forum Qt Tools
    Replies: 0
    Last Post: 25th August 2011, 13:15
  3. Clear Application Output Pane
    By paolo.saudin in forum Newbie
    Replies: 2
    Last Post: 7th May 2011, 11:05
  4. Automatic clearing of Application Output Pane
    By piotr.dobrogost in forum Qt Tools
    Replies: 0
    Last Post: 4th August 2009, 20:56
  5. font size in Application Output Pane
    By piotr.dobrogost in forum Qt Tools
    Replies: 0
    Last Post: 4th August 2009, 20:55

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.