Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. save a qchart with QMessageBox

save a qchart with QMessageBox

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 293 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lindaah
    wrote on last edited by lindaah
    #1

    hello I have a chart and I would like to make a QMessageBox for the choice if we want to save it or not how can i do it please
    to save the chart with the date it is with :
    QString fileim =QDateTime::currentDateTime().toString(QString("'%1/graphe_'yyyy_MM_dd'_'hh_mm_ss'.png").arg(dossier));
    QPixmap p = chartView->grab();
    p.save(fileim);

    chart code :
    QChart *chart = new QChart(); // Pointer sur charte
    chart->legend()->hide();
    chart->addSeries(series);
    chart->createDefaultAxes();
    chart->axes(Qt::Vertical).first()->setRange(-3, 3);
    chart->axes(Qt::Horizontal).first()->setRange(-10, 10);
    chart->setBackgroundBrush(QBrush(Qt::black));
    QChartView *chartView = new QChartView(chart);
    chartView->setRenderHint(QPainter::Antialiasing);
    QMainWindow window;
    window.setCentralWidget(chartView);
    window.resize(500, 500);
    window.show();

    JonBJ 1 Reply Last reply
    0
    • L lindaah

      hello I have a chart and I would like to make a QMessageBox for the choice if we want to save it or not how can i do it please
      to save the chart with the date it is with :
      QString fileim =QDateTime::currentDateTime().toString(QString("'%1/graphe_'yyyy_MM_dd'_'hh_mm_ss'.png").arg(dossier));
      QPixmap p = chartView->grab();
      p.save(fileim);

      chart code :
      QChart *chart = new QChart(); // Pointer sur charte
      chart->legend()->hide();
      chart->addSeries(series);
      chart->createDefaultAxes();
      chart->axes(Qt::Vertical).first()->setRange(-3, 3);
      chart->axes(Qt::Horizontal).first()->setRange(-10, 10);
      chart->setBackgroundBrush(QBrush(Qt::black));
      QChartView *chartView = new QChartView(chart);
      chartView->setRenderHint(QPainter::Antialiasing);
      QMainWindow window;
      window.setCentralWidget(chartView);
      window.resize(500, 500);
      window.show();

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by JonB
      #2

      @lindaah said in save a qchart with QMessageBox:

      I would like to make a QMessageBox for the choice if we want to save it or not how can i do it please

      Display the message box to ask the question, e.g. via https://doc.qt.io/qt-5/qmessagebox.html#question. Then save or not according to response.

      Or use QFileDialog to allow the user to pick a filename/path to save to, https://doc.qt.io/qt-5/qfiledialog.html#getSaveFileName. But not if you are wanting to control the filename/path, as per the filename code you are using.

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved