Last active
January 2, 2016 13:29
簡単なサインカーブ[0-360]:Qwt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mainwindow.h" | |
#include "ui_mainwindow.h" | |
#include <qwt_plot_curve.h> | |
MainWindow::MainWindow(QWidget *parent) : | |
QwtPlot(parent) | |
{ | |
setTitle( "Sin Curve" );//グラフのタイトル | |
QwtPlotCurve *curve = new QwtPlotCurve(); | |
curve->attach(this); | |
const int kArraySize = 37; | |
double plotX[kArraySize] = {}; // x | |
double plotY[kArraySize] = {}; // y | |
int i= 0; | |
for(int k = 0; k <= 360; k+=10 ){ | |
double x = k; | |
double y = sin(k*M_PI/180); | |
qDebug() << i << "::" << k << "::" << x <<"::"<<y; | |
plotX[i] = x; | |
plotY[i] = y; | |
++i; | |
} | |
curve->setSamples(plotX, plotY, kArraySize); | |
resize( 600, 400 ); | |
} | |
MainWindow::~MainWindow() | |
{ | |
delete ui; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment