久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Qt GUI 應(yīng)用程序中的控制臺輸出?

Console output in a Qt GUI app?(Qt GUI 應(yīng)用程序中的控制臺輸出?)
本文介紹了Qt GUI 應(yīng)用程序中的控制臺輸出?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我有一個在 Windows 上運行的 Qt GUI 應(yīng)用程序,它允許傳遞命令行選項,在某些情況下我想向控制臺輸出一條消息然后退出,例如:

I have a Qt GUI application running on Windows that allows command-line options to be passed and under some circumstances I want to output a message to the console and then quit, for example:

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);

  if (someCommandLineParam)
  {
    std::cout << "Hello, world!";
    return 0;
  }

  MainWindow w;
  w.show();

  return a.exec();
}

但是,當我從命令提示符運行應(yīng)用程序時,控制臺消息不會出現(xiàn).有誰知道我怎樣才能讓它發(fā)揮作用?

However, the console messages do not appear when I run the app from a command-prompt. Does anyone know how I can get this to work?

推薦答案

Windows 并不真正支持雙模式應(yīng)用程序.

Windows does not really support dual mode applications.

要查看控制臺輸出,您需要創(chuàng)建一個控制臺應(yīng)用程序

To see console output you need to create a console application

CONFIG += console

但是,如果您雙擊該程序以啟動 GUI 模式版本,則會出現(xiàn)一個控制臺窗口,這可能不是您想要的.為了防止控制臺窗口出現(xiàn),您必須創(chuàng)建一個 GUI 模式的應(yīng)用程序,在這種情況下,您將不會在控制臺中獲得任何輸出.

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.

一個想法可能是創(chuàng)建第二個小應(yīng)用程序,它是一個控制臺應(yīng)用程序并提供輸出.這樣就可以調(diào)用第二個來做工作了.

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.

或者您可以將所有功能放在一個 DLL 中,然后創(chuàng)建兩個版本的 .exe 文件,它們具有調(diào)用 DLL 的非常簡單的主要函數(shù).一種用于 GUI,一種用于控制臺.

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.

這篇關(guān)于Qt GUI 應(yīng)用程序中的控制臺輸出?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數(shù)據(jù)?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環(huán): for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環(huán)?)
Reusing thread in loop c++(在循環(huán) C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環(huán)形?)
主站蜘蛛池模板: 一二区视频 | 久久一区二区视频 | 成人三级晚上看 | 成人在线观看网址 | 性欧美8khd高清极品 | 在线免费观看黄色片 | 免费黄色一级 | 中国第一毛片 | 成人在线网 | 欧美一区二区三区在线播放 | 国产精品久久久久久精 | 欧美三级在线视频 | 福利视频网站 | 亚洲精品91天天久久人人 | 99re国产| 天天干天天操 | 日本高清www | 日日日日干 | 日韩一级淫片 | 天天综合永久入口 | 999精品在线 | 国产伦精品一区二区三区88av | 久久视频一区 | 青青草久久 | 国产成人精品一区二区三区福利 | 久久精品二区 | 黄色免费网站视频 | av老司机在线 | 免费一级a毛片 | 国产情侣在线播放 | 男男巨肉啪啪动漫3d | 在线观看小视频 | 91免费版看片 | 精品婷婷| 欧美亚洲一区二区三区 | 国产在线观看网站 | 久久一级片 | 五月天婷婷激情 | 久久国产一区二区三区 | 韩日一级片 | 97精品国产露脸对白 |