Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[Solved] Show / hide console window



  • Hi Folks,

    I'm googling since a day, but my issue seems to be opened already. I have a console application on Windows 7, that I have to push down to the Windows Tray (collection of icons at the right - bottom side) when the user clicks on the "hide" control of the console window. I discovered, that I have to add "widgets" library to my project (I started from console application) and I can use QSystemTrayIcon for this purposes.
    The question is: how can hide the console window itself and show it again if the user click on the icon on the system tray?
    I didn't have to found such a solution (show() and hide() slots) as I can use on QMainwindow instance. And I would like to avoid winAPI calls. I prefer the clean Qt solutions:)

    Can anybody help me?

    Regards,
    Norbert


  • Moderators

    A popular misconception is that the console window is part of your app. It is not. When you create a console app your app has no window. All it does is read/write to/from the standard input/output. The window you see is provided by OS and is a separate entity. So it's not a widget and as such, can't be controlled by Qt.

    So your options include:

    • Use WinAPI to find the window that hosts your app and ask it to minimize, show etc. via Windows messages.
    • Switch to ui application and emulate a console as a widget
    • Switch to ui application with no widget and spawn your own console instance. Talking to it requires WinAPI calls.

Log in to reply