Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved [Solved] Show / hide console window

    General and Desktop
    2
    2
    2166
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      moravas last edited by moravas

      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

      1 Reply Last reply Reply Quote 0
      • Chris Kawa
        Chris Kawa Moderators last edited by

        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.
        1 Reply Last reply Reply Quote 0
        • First post
          Last post