2014-04-23 6 views
1

을하지 않았다 :의 peice (즉, 빈 창을 보여주는 유지) 여기에 코드를</p> <p>mainwindow.h이다 싶어 작업 (작은 예제 코드) 내가 작동하지 않았다 QT 코드 조각이

#include <QMainWindow> 
#include <QTimer> 
#include "qcustomplot.h" 
#include <qcustomplot.h> 

class MainWindow : public QMainWindow 
{ 
public: 
    MainWindow(QWidget *parent = 0); 

}; 

mainwindow.cpp : 


#include "mainwindow.h" 
#include <QDebug> 
#include <QDesktopWidget> 
#include <QScreen> 
#include <QMessageBox> 
#include <QMetaEnum> 
#include <iostream> 

using namespace std; 

MainWindow::MainWindow(QWidget *parent) : 
    QMainWindow(parent) 

{ 
    QCustomPlot *customPlot = new QCustomPlot; 
    cout<<"srsly wtf!!!!"<<endl; 
    // generate some data: 
    QVector<double> x(101), y(101); // initialize with entries 0..100 
    for (int i=0; i<101; ++i) 
    { 
    x[i] = i/50.0 - 1; // x goes from -1 to 1 
    y[i] = x[i]*x[i]; // let's plot a quadratic function 
    } 
    // create graph and assign data to it: 
    customPlot->addGraph(); 
    customPlot->graph(0)->setData(x, y); 
    // give the axes some labels: 
    customPlot->xAxis->setLabel("x"); 
    customPlot->yAxis->setLabel("y"); 
    // set axes ranges, so we see all data: 
    customPlot->xAxis->setRange(-1, 1); 
    customPlot->yAxis->setRange(0, 1); 
    customPlot->replot(); 

} 

MAIN.CPP이 http://www.qcustomplot.com/images/examples/quadraticdemo.png

같은

#include <QApplication> 
#include "mainwindow.h" 

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

    return a.exec(); 
} 

그 결과가해야 뭔가

는 여기 http://www.qcustomplot.com/index.php/download

답변

1

를 볼 수 있습니다 QCustomPlot 라이브러리를 사용 당신이에 :
1 만들 위젯을
QCustomPlot 클래스 2 PROMOT이
2 사용 QCustomPlot로 위젯을 만들거나 QCustomPlot 포인터 위젯 가리 키도록 설정합니다

QCustomPlot *customPlot = ui->widget; 

또는

ui->widget->addGraph(); ..... 

계속 하시겠습니까?
* QCustomPlot에는 위젯을 그려야합니다.