Qt Creator和math.h不起作用

Qt Creator和math.h不起作用,qt,math.h,Qt,Math.h,我已经与Qt Creator启动了一个Qt项目,我想使用一些数学函数。我包括了数学。但是当我想使用一个函数时,我得到一个错误,该函数没有在这个范围内声明。我也试过mathc,但后来我在cmath中犯了20多个错误。我尝试了新的Ubuntu 12安装和最新版本的Qt Creator以及Windows 7。两个系统产生相同的错误。我做错了什么 #include <QtGui/QApplication> #include "mainwindow.h" #include <QDeskt

我已经与Qt Creator启动了一个Qt项目,我想使用一些数学函数。我包括了数学。但是当我想使用一个函数时,我得到一个错误,该函数没有在这个范围内声明。我也试过mathc,但后来我在cmath中犯了20多个错误。我尝试了新的Ubuntu 12安装和最新版本的Qt Creator以及Windows 7。两个系统产生相同的错误。我做错了什么

#include <QtGui/QApplication>
#include "mainwindow.h"
#include <QDesktopWidget>
#include <QStyle>
#include <math.h>
#include <iostream>

using namespace std;


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

   w.setGeometry(
    QStyle::alignedRect(
        Qt::LeftToRight,
        Qt::AlignCenter,
        w.size(),
        qApp->desktop()->availableGeometry()
    ));
   w.show();
   int i= pow(2,2);
   return a.exec();
}
#包括
#包括“mainwindow.h”
#包括
#包括
#包括
#包括
使用名称空间std;
int main(int argc,char*argv[])
{
质量保证申请a(argc、argv);
主窗口w;
w、 集合几何(
QStyle::alignedRect(
Qt::LeftToRight,
Qt::AlignCenter,
w、 大小(),
qApp->desktop()->availableGeometry()
));
w、 show();
int i=功率(2,2);
返回a.exec();
}

这个问题可能已经过时,但无论如何:

您可以包括
qmath.h

#include <qmath.h>

另请参见发布示例错误消息。另外,QtCreator的代码分析是否能正确读取函数(比如,代码下面是否有扭曲的红线或黄线)?错误消息:…Qt_4_8_1_in_Pfad_系统_发布/./Simulator/main.cpp:26:Fehler:'pow'未在此范围内声明您的代码对我来说运行良好(显然减去
主窗口的内容),所以可以肯定地说,这不是Qt问题,而是您的系统。如果在QtCreator中按住ctrl键并右键单击
math.h
,文件是否打开?我解决了它!在我的项目文件夹中有一个叫做“数学”的类,是我几个月前创建的。所以Qt包含了错误的文件,当然,现在它可以工作了。至少ctrl单击的提示告诉了我如何找到错误的头文件,Thx就是这样
qPow(2, 2); //instead of pow(2, 2)