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

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

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

問題描述

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

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();
}

但是,當(dāng)我從命令提示符運(yùn)行應(yīng)用程序時(shí),控制臺(tái)消息不會(huì)出現(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.

要查看控制臺(tái)輸出,您需要?jiǎng)?chuàng)建一個(gè)控制臺(tái)應(yīng)用程序

To see console output you need to create a console application

CONFIG += console

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

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.

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

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.

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

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)用程序中的控制臺(tái)輸出?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)形?)
主站蜘蛛池模板: 亚洲精品久久嫩草网站秘色 | 日本黄色免费大片 | 亚洲成人播放器 | 亚洲午夜精品一区二区三区他趣 | 超碰美女在线 | 国产成人精品免高潮在线观看 | 免费成人av网站 | 夜夜夜操| 日韩精品在线免费 | 午夜爽爽男女免费观看hd | 国产欧美精品一区二区 | 九色 在线 | 国产成人综合久久 | 成人国产一区二区三区精品麻豆 | 国产精品久久久久不卡 | 91精品国产综合久久婷婷香蕉 | 亚洲一区欧美 | 久久99精品视频 | 国产精品777一区二区 | 亚洲综合色视频在线观看 | 精品成人佐山爱一区二区 | 国产999精品久久久 精品三级在线观看 | 亚洲精品久久区二区三区蜜桃臀 | 日韩激情视频一区 | 中文字幕综合 | 玖玖视频国产 | 伊人久久精品一区二区三区 | 久久婷婷麻豆国产91天堂 | 性生活毛片 | 欧美精品乱码99久久影院 | 国产一区二区在线看 | 亚洲区一区二区 | 在线视频日韩精品 | 91在线视频播放 | av成人在线观看 | 国产欧美精品区一区二区三区 | 欧美在线视频一区 | 亚洲精品视频免费观看 | а天堂中文最新一区二区三区 | 亚洲午夜视频 | 91视频在线网站 |