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. Problem in QCustomPlot class
Forum Updated to NodeBB v4.3 + New Features

Problem in QCustomPlot class

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 4.1k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    Swinetha
    wrote on last edited by
    #1

    hai I am using QCustomPlot in one of my application.

    while adding graph application is unexcpectedly closed

    in my mainwindow.cpp

    m_pCustomPlot->addGraph();(M_pCustomPlot is QCustomPlot*)

    @
    QCPGraph *QCustomPlot::addGraph(QCPAxis *keyAxis, QCPAxis *valueAxis)
    {
    if (!keyAxis) keyAxis = xAxis;
    if (!valueAxis) valueAxis = yAxis;
    if (!keyAxis || !valueAxis)
    {
    qDebug() << Q_FUNC_INFO << "can't use default QCustomPlot xAxis or yAxis, because at least one is invalid (has been deleted)";
    return 0;
    }
    if (keyAxis->parentPlot() != this || valueAxis->parentPlot() != this)
    {
    qDebug() << Q_FUNC_INFO << "passed keyAxis or valueAxis doesn't have this QCustomPlot as parent";
    return 0;
    }
    @

    in above code while assigning xAxis to keyAxis The program has unexpectedly finished.

    and

    ploting initialisation is as shown below
    @
    m_pCustomPlot->setWindowFlags(Qt::FramelessWindowHint);

    m_pCustomPlot->setMinimumSize(210,240);
    m_pCustomPlot->setGeometry(0,70,240,240);
    m_pCustomPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectAxes | QCP::iSelectLegend | QCP::iSelectPlottables);
    
    QFont legendFont = font();
    legendFont.setPointSize(8);
    

    m_pCustomPlot->xAxis->setRange(0,16384);
    m_pCustomPlot->yAxis->setRange(0,20000);
    m_pCustomPlot->axisRect()->setupFullAxesBox();

    m_pCustomPlot->plotLayout()->insertRow(0);
    
    m_pCustomPlot->xAxis->setLabel("Bin");
    m_pCustomPlot->xAxis->setLabelFont(legendFont);
    m_pCustomPlot->yAxis->setLabelFont(legendFont);
    m_pCustomPlot->yAxis->setLabel("Bin Count");
    

    @

    can any one please suggest me where I did mistake?

    Thanks in advance

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you correctly initialize (as in allocate) m_pCustomPlot ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Swinetha
        wrote on last edited by
        #3

        yes I did.
        @
        m_pCustomPlot = NULL;
        if(m_pCustomPlot == NULL){
        m_pCustomPlot = new QCustomPlot();
        m_pCustomPlot->setGeometry(0,0,120,80);
        m_pCustomPlot->resize(120,80);
        }
        @

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Then, run your program using the debugger, it will give you more information about what happens when it crashes

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Swinetha
            wrote on last edited by
            #5

            My project was in Debug mode but it's not giving any information.

            I have one more doubt, Can I use QCustomPlot to plot the graph continuously means can i update the garph for evry one sec.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              For such specialized question, you should contact the author of the library directly

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

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