crossplatform.ru

Здравствуйте, гость ( Вход | Регистрация )

> [QWT] Отображаются оси, но не отображается график
rcdimon
  опции профиля:
сообщение 27.10.2009, 15:11
Сообщение #1


Студент
*

Группа: Участник
Сообщений: 69
Регистрация: 27.10.2009
Пользователь №: 1183

Спасибо сказали: 1 раз(а)




Репутация:   0  


Наверное вопрос глупый, но я уже 2 часа потерял из-за него. Оси отображаются, подписываются, шкала правильная, а графика нет. То есть мои данные на нем не рисуются.

Код.

Test_qwt::Test_qwt(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)
{
    ui.setupUi(this);

    double X1[20], Y1[20],X2[20], Y2[20];
    int Size,i;

    Size = 20;

    for (i=0;i<20;i++){
        X1[i] = rand()/32;
        Y1[i] = rand()/32;
        X2[i] = rand()/32;
        Y2[i] = rand()/32;
    }

    QwtPlot *myPlot = new QwtPlot(this);
    setCentralWidget(myPlot);

    // Disable polygon clipping
    QwtPainter::setDeviceClipping(false);

    // We don't need the cache here
    myPlot->canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false);


    QwtPlotMarker *mY = new QwtPlotMarker();
    mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
    mY->setLineStyle(QwtPlotMarker::HLine);
    mY->setYValue(0.0);
    mY->attach(myPlot);

    // add curves
    QwtPlotCurve *curve1 = new QwtPlotCurve("Curve 1");
    QwtPlotCurve *curve2 = new QwtPlotCurve("Curve 2");

    curve1->setPen(QPen(Qt::red));
    curve1->setStyle(QwtPlotCurve::Lines);
    curve2->setPen(QPen(Qt::blue));
    curve2->setStyle(QwtPlotCurve::Lines);

    
    // copy the data into the curves
    curve1->setData(X1,Y1,Size);
    curve2->setData(X2,Y2,Size);

    curve1->attach(myPlot);
    curve2->attach(myPlot);

    // Axis
    myPlot->setAxisTitle(QwtPlot::xBottom, "Time/seconds");
    myPlot->setAxisScale(QwtPlot::xBottom, 0, 100);

    myPlot->setAxisTitle(QwtPlot::yLeft, "Values");
    myPlot->setAxisScale(QwtPlot::yLeft, 50, 300);


    // finally, refresh the plot
    myPlot->replot();

}
Перейти в начало страницы
 
Быстрая цитата+Цитировать сообщение

Сообщений в этой теме


Быстрый ответОтветить в данную темуНачать новую тему
Теги
Нет тегов для показа


1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0




RSS Текстовая версия Сейчас: 29.3.2024, 13:43