码迷,mamicode.com
首页 > 其他好文 > 详细

Qt GUI程序带命令行

时间:2021-01-28 12:25:20      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:and   www   tput   users   wan   tail   lse   ber   gui   

Windows does not really support dual mode applications.

To see console output you need to create a console application

CONFIG += console

However, if you double click on the program to start the GUI mode version then you will get a console window appearing, which is probably not what you want. To prevent the console window appearing you have to create a GUI mode application in which case you get no output in the console.

One idea may be to create a second small application which is a console application and provides the output. This can call the second one to do the work.

Or you could put all the functionality in a DLL then create two versions of the .exe file which have very simple main functions which call into the DLL. One is for the GUI and one is for the console.

  •  
    Yes, this is what I‘ve come to realise - two apps! – Rob Jul 30 ‘10 at 9:01
  •  
    Having a small console app to call the main GUI app is fine, but is there any way to feed back the output to the console app in real time so the user can see what‘s going on, or to show typical output for things like -h, --version etc? – iforce2d May 27 ‘13 at 7:11
  •  
  • 3
    You can free the console by calling FreeConsole. So your application may decide in which mode it will work and then hide the console if running in GUI mode. – Alexander Dunaev Jun 10 ‘13 at 2:57
  •  
    Be warned that FreeConsole has incredibly dangerous behaviour on Windows 8: stackoverflow.com/questions/12676312/… – Kim Jun 29 ‘17 at 12:10

Qt GUI程序带命令行

标签:and   www   tput   users   wan   tail   lse   ber   gui   

原文地址:https://www.cnblogs.com/liujx2019/p/14338320.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!