Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/152.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 字符串尚未声明,QT_C++_Qt - Fatal编程技术网

C++ 字符串尚未声明,QT

C++ 字符串尚未声明,QT,c++,qt,C++,Qt,我正在尝试更改某个文本框消息。它将显示我的输出 这是我的主要内容() 182::Form2::changeOutput(recvMSG); 在我的表格2.h中,我有: #include <string.h> #include <iostream> #include <stdlib.h> ... void Form2::changeOutput(string s) { QString s1 = i18n(s);

我正在尝试更改某个文本框消息。它将显示我的输出

这是我的主要内容()

182::Form2::changeOutput(recvMSG);

在我的表格2.h中,我有:

#include <string.h>    
#include <iostream>
#include <stdlib.h>    
...
    void Form2::changeOutput(string s)
    {
    QString s1 = i18n(s);
    output_box.setText(s1);

    }
#包括
#包括
#包括
...
void Form2::changeOutput(字符串s)
{
QString s1=i18n(s);
输出_box.setText(s1);
}
但我仍然得到: .ui/form2.h:56:错误:“字符串”尚未声明

谢谢

编辑::kk现在显示::
TCPClient.cpp:182:错误:无法调用没有对象的成员函数“virtual void Form2::changeOutput(std::string)”
string
位于
std
命名空间中,因此您需要将其称为
std::string
,或者,您需要使用名称空间std使名称在当前范围内可用
使用std::string

另外,标题名为
string
,而不是
string.h
,因此应以这种方式包含它:

#include <string>
#包括

通常,如果您将QT的
QString
与通常采用
QString
参数的QT组件结合使用,您可能还希望使用QT的
QString
而不是
std::string

我想您应该使用标题
,然后使用
std::string
(更好的方法是
const std::string&

更好的方法是不要混合使用STL和Qt字符串类和容器。确实如此,但有时您希望隐藏在类接口中使用的库的内部数据类型,以避免客户端必须包含第三方头。这都是间接的。
#include <string>