Results 1 to 8 of 8

Thread: Windows weird console behaviour - stopped displaying output

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2015
    Posts
    8
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Windows weird console behaviour - stopped displaying output

    Hi,

    I'm currently upgrading and porting a Linux App (Ubuntu 14.04) to windows 7 (Qt Creator 2.1.0 (Qt 4.7.1) + Mingw-w64: --> this is a requisite, not my choice.), and encounter a weird issue.

    For debugging reasons i printf lots of info to console, in the linux enviroment it appears in the Qt Creator "Application Output" tab.
    In Windows it "used to" appear in an addtional console, and i said "used to" because, the output disappear from one day to another, and i can't find the reason (meaning where did i break it).

    In my windows .PRO i have
    CONFIG += console

    In "Projects --> Run Settings --> Run in Terminal" is checked

    WEIRD BEHAVIOUR:
    When i run the windows app from Qt Creator, the terminal is opened but no output is displayed (App is working but printfs not printing to console).

    If I launch the .exe from windows console (cmd.exe) no output is displayed, in fact, launches the app and the console returns ready for new inputs.

    If I launch the .exe form the MSYS2 console I get NEARLY the desired behaviour, i can see the output messages and the App "owns" the terminal untill I close the App, but it has some issues with the flussing of the info. Some lines are ketp in the buffer and not printed untill some other action triggers the buffering flushing.


    I suspect that it should be a IDE configuration parameter, but i don't have a clue of what it could be.


    Any idea about what's happening?
    Last edited by QTapprentice; 2nd December 2016 at 13:24. Reason: more descriptive description

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Windows weird console behaviour - stopped displaying output

    console output on Windows is always problematic, even if it works in can be highly buffered, etc.

    Have you tried without the "run in terminal" option? Does it display the output in the Application Output tab?

    Alternatively you could try redirecting the output to a file, e.g.

    application > file.out

    and watch that file (assuming that can somehow be done on Windows).

    Cheers,
    _

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Windows weird console behaviour - stopped displaying output

    and watch that file (assuming that can somehow be done on Windows).
    If you open the file using Notepad++, it will notify you that the file has changed on disk and ask if you want to reload. It doesn't reload the file automatically in real time, but does watch the file for changes. I use this for watching log and other large output text files. The reload on demand feature is actually more useful than an automatic reload because you are in charge of when the window content gets updated and aren't forced to watch output stream by while you try to read it, as you would with a console window.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  4. #4
    Join Date
    Dec 2015
    Posts
    8
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Windows weird console behaviour - stopped displaying output

    Thanks for the answers to bouth,

    This is the behaviour that i get:

    run in console CONFIG+=console behaviour
    ------------------------------------------------------------------------------------------
    yes yes open console does not print anything.
    no yes does not open console
    yes no open console does not print anything.
    no no does not open console

    If i redirect the output from the cmd.exe "App.exe >> output.txt" does not show anything in the console and the output file is empty.

    For now, I can work calling the app from the MSYS2 console and redireccting the output to a file but is way less usefull than watching the output in console in real time as the app has a communications module and i like to see what is going trough the console.

    Thanks again for the answers, any other idea would be greatly wellcome.
    Last edited by QTapprentice; 5th December 2016 at 11:13. Reason: reformatted to look better

  5. #5
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Windows weird console behaviour - stopped displaying output


  6. #6
    Join Date
    Dec 2015
    Posts
    8
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Windows weird console behaviour - stopped displaying output

    Thanks for the advice Lesiok,

    But, QT 4.7 is a prerequisite and qInstallMessageHandler was introduced in Qt5.0

    Also, I have a lot of debug messages printed to stderr in some lowlevel C99 static linked libraries that i would like to see (not sure if qInstallMesageHandler will catch them due to my own ignorance of the function).

    Also, all this messages were printing ok in previous versions of the app, (not anymore), wich tells me that it is some Qt Creator config feature that I unwillingly modified.

    Any other suggestion will be greatly appreciated.

  7. #7
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Windows weird console behaviour - stopped displaying output

    In Qt 4 this function is qInstallMsgHandler.

  8. #8
    Join Date
    Dec 2015
    Posts
    8
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Windows weird console behaviour - stopped displaying output

    Ok, i did try the qInstallMsgHandler but to no avail... it behaves like my own debugging functions.

    Only prints out if i call the exe from the MSYS2 console and buffers contents.

    The console that opens from the QtCreator doesn't show anything.

Similar Threads

  1. Weird Android behaviour
    By ObiWanKenobe in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 28th May 2015, 10:57
  2. Weird QwtPlotCurve Behaviour
    By yannwilfried in forum Qwt
    Replies: 2
    Last Post: 18th July 2013, 17:02
  3. weird behaviour with QItemSelectModel
    By Bebert218 in forum Qt Programming
    Replies: 0
    Last Post: 8th July 2011, 03:02
  4. Weird behaviour of QToolButton on a tablet PC with Windows 7
    By ChiliPalmer in forum Qt Programming
    Replies: 0
    Last Post: 9th March 2011, 21:39
  5. Model/View weird behaviour - Windows/Mingw
    By incapacitant in forum Newbie
    Replies: 7
    Last Post: 23rd March 2006, 23:21

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.