crossplatform.ru

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

История благодарностей участнику Steklova Olga ::: Спасибо сказали: 5 раз(а)
Дата поста: В теме: За сообщение: Спасибо сказали:
23.3.2015, 16:06 Как в QCustomPlot убрать сетку с графика?
Смотри комментарии к методам класса в файле qcustomplot.cpp

  customPlot->yAxis->setVisible(true);
  customPlot->yAxis->setAutoTicks(false);
  //customPlot->yAxis->setAutoTickLabels(false);
  customPlot->yAxis->setTickVector(QVector<double>());
  //customPlot->yAxis->setTickVectorLabels(QVector<QString>());
  //customPlot->yAxis->setAutoSubTicks(false);
  //customPlot->yAxis->setSubTickCount(0);
Аналогично для xAxis, yAxis2, xAxis2.
0v.v0,
30.10.2014, 20:13 кто-то работал с qcustomplot ?
Цитата(skyer_ @ 14.10.2014, 21:27) *
Приветствую, нужен совет как нарисовать горизонтальные гистограммы на qcustomplot.

  QCPCurve *gr1 = new QCPCurve(customPlot->xAxis, customPlot->yAxis);
  QCPCurve *gr2 = new QCPCurve(customPlot->xAxis, customPlot->yAxis);
  customPlot->addPlottable(gr1);
  customPlot->addPlottable(gr2);
  gr1->setPen(QPen(Qt::darkGreen, 50, Qt::SolidLine));
  gr2->setPen(QPen(Qt::darkGreen, 50, Qt::SolidLine));
  int pointCount = 2;
  QVector<double> x(pointCount), y(pointCount);
  x[0] = 0.0; x[1] = 120.0;  y[0] = 20.0; y[1] = y[0];
  gr1->setData(x, y);
  x[0] = 0.0; x[1] = 150.0;  y[0] = 50.0; y[1] = y[0];
  gr2->setData(x, y);
  customPlot->axisRect()->setupFullAxesBox();
  customPlot->xAxis->setRange(0.0, 200.0);
  customPlot->yAxis->setRange(0.0, 100.0);
skyer_,
29.8.2014, 18:05 кто-то работал с qcustomplot ?
а для оцифровки
on_btn_green_check_clicked()
void MainWindow::on_btn_green_check_clicked()
{
    disconnect(ui->customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), ui->customPlot->xAxis2, SLOT(setRange(QCPRange)));
    disconnect(ui->customPlot->yAxis, SIGNAL(rangeChanged(QCPRange)), ui->customPlot->yAxis2, SLOT(setRange(QCPRange)));

    //все графики кроме зеленого переключаем на 2-ю неподвижную оцифровку
    ui->customPlot->graph(0)->setKeyAxis(ui->customPlot->xAxis2);
    ui->customPlot->graph(0)->setValueAxis(ui->customPlot->yAxis2);
    ui->customPlot->graph(1)->setKeyAxis(ui->customPlot->xAxis2);
    ui->customPlot->graph(1)->setValueAxis(ui->customPlot->yAxis2);

    ui->customPlot->xAxis->setBasePen(QPen(Qt::green, 2));
    ui->customPlot->yAxis->setBasePen(QPen(Qt::green, 2));

    //dop
//    ui->customPlot->yAxis->setVisible(true);
    ui->customPlot->yAxis->setAutoTicks(false);
    ui->customPlot->yAxis->setAutoTickLabels(false);
    ui->customPlot->yAxis->setAutoSubTicks(false);
    ui->customPlot->yAxis->setTickVector(QVector<double>()
        << 1.0 << 2.0 << 3.0);
    ui->customPlot->yAxis->setTickVectorLabels(QVector<QString>()
        << "1,0" << "2,0" << "3,0");
    //dop

    ui->customPlot->replot();
}
on_btn_green_uncheck_clicked()
void MainWindow::on_btn_green_uncheck_clicked()
{
    ui->customPlot->yAxis->setRange(ui->customPlot->yAxis2->range()); //можно это не делать (или делать, если нужно)

    connect(ui->customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), ui->customPlot->xAxis2, SLOT(setRange(QCPRange)));
    connect(ui->customPlot->yAxis, SIGNAL(rangeChanged(QCPRange)), ui->customPlot->yAxis2, SLOT(setRange(QCPRange)));

    //все графики кроме зеленого возвращаем на 1-ю подвижную оцифровку
    ui->customPlot->graph(0)->setKeyAxis(ui->customPlot->xAxis);
    ui->customPlot->graph(0)->setValueAxis(ui->customPlot->yAxis);
    ui->customPlot->graph(1)->setKeyAxis(ui->customPlot->xAxis);
    ui->customPlot->graph(1)->setValueAxis(ui->customPlot->yAxis);

    ui->customPlot->xAxis->setBasePen(QPen(Qt::black));
    ui->customPlot->yAxis->setBasePen(QPen(Qt::black));

    //dop
//    ui->customPlot->yAxis->setVisible(false);
    ui->customPlot->yAxis->setAutoTicks(true);
    ui->customPlot->yAxis->setAutoTickLabels(true);
    ui->customPlot->yAxis->setAutoSubTicks(true);
    //dop

    ui->customPlot->replot();
}
_Vitaliy_,
11.4.2012, 11:27 знакомство с SQL
"Базы данных. Язык SQL для Студента" Дунаев В.В.
ArhiZhek,
3.3.2012, 19:27 QDialog
Ov3r1oad, а не проще ли тогда вместо использования QProgressDialog
создать просто виджет, на котором разместить QProgressBar и QLabel? И делайте тогда с ними, что хотите :clapping:
Ov3r1oad,

RSS Текстовая версия Сейчас: 16.2.2025, 18:52