Important: Please read the Qt Code of Conduct  https://forum.qt.io/topic/113070/qtcodeofconduct
Squarefunction

Hey, guys. I want to creat a chart with an Square signal. I already wrote the function from the fourier transformation. But i only get a sinus function.
double SimRechteckSensor::getValue() { static double x; double fx; fx=(4/M_PI)*((sin(x))+((1/3)*sin(3*x))+((1/5)*sin(5*x))+((1/7)*sin(7*x))+((1/9)*sin(9*x))); x+=0.1; return fx; }

I haven't done this kind of math in around 10 years but isn't the square wave the limit of the fourier (i.e. you need infinite armonics to obtain it) making it impossible in practice to build that way?

yes thats true. But if you want to get a chart with a fourier transformation, i found out, that you have to type in:
fx=(4/M_PI)*((sin(x))+((1/3.0)sin(3x))+((1/5.0)*sin(5x))+((1/7.0)sin(7x))+((1/9.0)sin(9x)));
Because you are trying to divide a integer by integer. That gives you a integer back. In this case its zero. When you typ for example 3.0 insted of 3 you divide integer by double and then you get a double back. Now simply find a good solution for x to get a nice chart. Should be working. But, how VRonin said, its not a real square Chart (watch youtube).In my program i programmed some if else cases that gives me for y value 1 or 0 back.