本文介绍了在Qt中显示控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我想为我的应用程序添加一个控制台,这里是我的问题。 在Qt Creator中,我创建一个新项目, ,将其从使用 QCoreApplication 转换为 QApplication ,添加 core gui 小部件到项目文件中的 QT ,它的工作原理。我可以创建窗口同时有一个控制台窗口。所以项目文件看起来像这样... QT + = core gui widgets TARGET = ConsoleApp CONFIG + = console CONFIG - = app_bundle TEMPLATE = app #sources ... pre> 这是完美的工作,我可以用这个开发一个完整的GUI应用程序;但是,该应用程序已经构建。当我为应用程序创建项目时,我选择了Qt Widgets应用程序。所以我想我可以把ConsoleApp的项目文件的配置复制到我的应用程序的项目文件。所以我的应用程序项目文件看起来像这样... QT + = core gui widgets TARGET = GuiApp CONFIG + = console CONFIG - = app_bundle TEMPLATE = app #sources ... 但这不是给我一个控制台,我不明白为什么。我知道我可以创建一个控制台应用程序,只是转移我的源,在哪里解决我的问题,但我想知道...为什么控制台不显示在我的GUI应用程序,尽管使用完全相同的配置作为控制台应用程序在项目文件中? 我正在使用Qt 5.3.1编译MSVC2013 OpenGL 64bit在Windows 8 64位,所有在Qt Creator 3.1.2 解决方案默认情况下,GUI应用程序没有在QtCreator中启用终端。启用它很简单: 在左侧栏中,点击项目 > I want to add a console to my application, and here's my problem.In Qt Creator, I create a new Project, I select 'Qt Console Application', convert it from using QCoreApplication to QApplication, add core gui widgets to the QT configuration flag in the project file, and it works. I can create windows while having a console window. So the project file looks like this...QT += core gui widgetsTARGET = ConsoleAppCONFIG += consoleCONFIG -= app_bundleTEMPLATE = app#sources...This is working perfectly and I could develop a full GUI app with this; however, the app is already built. When I created the project for the app, I chose 'Qt Widgets Application'. So I thought I could just copy the configuration of the ConsoleApp's project file over to my app's project file. So My apps project file looks like this...QT += core gui widgetsTARGET = GuiAppCONFIG += consoleCONFIG -= app_bundleTEMPLATE = app#sources...But this is not showing me a console and I don't understand why. I know I could just create a Console Application and just transfer my source over which right there solves my problem, but I wanna know... why is the console not showing up in my GUI app despite using the exact same configuration as the console app in the project file?I'm compiling with Qt 5.3.1 MSVC2013 OpenGL 64bit on Windows 8 64bit, all in Qt Creator 3.1.2 解决方案 By default, GUI apps don't have the terminal enabled in QtCreator. Enabling it is simple:In the left sidebar, click ProjectsAt the top, select your project's Run tabIn the Run section, check the Run in terminal checkbox 这篇关于在Qt中显示控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-05 19:43