没有输出到控制台?

时间:2015-12-08 18:22:03

标签: c++ qt oop

我正在尝试学习C ++ OOP,思考会尝试使用Qt Creator的简单示例。我点击了New Project>项目>申请> Qt控制台应用程序

然后我添加了一个新类test.cpp。 test.cpp和main.cpp都在Sources文件夹中,test.h在Headers文件夹中。

这是test.h

#include "test.h"
#include "iostream"

using namespace std;

test::test()
{
   cout<<"Inside test's constructor "<<endl;
}

TEST.CPP

#include "iostream"
#include "test.h"

using namespace std;

int main()
{

   test ts;

   return 0;
}

的main.cpp

_url

当我点击运行按钮时,它已构建并运行。控制台窗口显示但是&#34; Inside test的构造函数&#34;永远不会被打印到屏幕上。我做错了什么?

2 个答案:

答案 0 :(得分:1)

转到Qt Creator中的首选项,选择环境。您将在“常规”选项卡下看到两个框。它们是用户界面和系统。

在系统下,您将看到

终端:

我说

/ usr / X11 / bin / xterm -e

尝试使用现有的终端。这在一些系统上已经存在一段时间了。

答案 1 :(得分:0)

我不再费心处理cout,控制台等问题而只是使用QDebug

qDebug() << "Date:" << QDate::currentDate();
qDebug() << "Types:" << QString("String") << QChar('x') << QRect(0, 10, 50, 40);
qDebug() << "Custom coordinate type:" << coordinate;
#include "test.h"
#include "iostream"
#include <QDebug>

using namespace std;

test::test()
{
   qDebug()<<"Inside test's constructor ";
}
相关问题