Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. [SOLVED] [Qwt and a DB] How to plot data coming from a DB with Qwt
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] [Qwt and a DB] How to plot data coming from a DB with Qwt

Scheduled Pinned Locked Moved 3rd Party Software
4 Posts 2 Posters 4.8k 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.
  • V Offline
    V Offline
    valandil211
    wrote on last edited by
    #1

    Hello Qt devs!

    I have written this so far, but the code won't compile:

    @
    xAxisTime = new QSqlQuery;
    xAxisTime->prepare("SELECT date(qa."QA_Timestamp") FROM "v_TestResults"");
    xAxisTime->exec();
    xAxisTime->next();

    // Preperation of general query to fetch test results
    yAxis = new QSqlQuery;
    yAxis->prepare("SELECT \"OUT_Output\" FROM \"v_TestResults\" WHERE \"OUT_IndexResultat\" = :idtest, \"OUT_Minor\" = :row, \"OUT_Minor\" = :col");
    yAxis->bindValue(":idtest", 20);
    yAxis->bindValue(":row", 1);
    yAxis->bindValue(":col", 1);
    yAxis->exec();
    yAxis->next();
    
    plotDsi0 = new QwtPlotCurve(trUtf8("DSI0"));
    plotDsi0->setAxis(QwtPlot::xBottom, QwtPlot::yLeft);
    plotDsi0->setData(xAxisTime->value(1).toDouble(), yAxis->value(1).toDouble(),
                      yAxis->size());
    
    plotDsi0->attach(CKV2_qwtPlot);
    

    @

    The compiler complains: that

    @
    there is no matching function call to 'QwtPlotCurve::setData(double, double, int)'
    @

    However, there is a candidate that is:

    @
    QwtPlotcurve:: setData(const double*, const double*, int)
    @

    I guess I could use vectors, but I'm not familiar with them, yet. Is there another way to proceed?

    Thanks for your tips!

    Joey Dumont

    1 Reply Last reply
    0
    • S Offline
      S Offline
      soroush
      wrote on last edited by
      #2

      you should pass pointers to your function.
      @
      double x = xAxisTime->value(1).toDouble();
      double y = yAxis->value(1).toDouble();
      plotDsi0->setData(&x, &y, yAxis->size());
      @

      EDIT:

      Primitives have ctors, so this will work too:
      @
      plotDsi0->setData(new double(xAxisTime->value(1).toDouble()), new double(yAxis->value(1).toDouble()),
      yAxis->size());
      @

      1 Reply Last reply
      0
      • V Offline
        V Offline
        valandil211
        wrote on last edited by
        #3

        Pointers to the QSqlQuery? But that won't return the actual record stored in the query. Plus, it won't return a double. I'm not sure I understand what you mean.

        Joey Dumont

        1 Reply Last reply
        0
        • V Offline
          V Offline
          valandil211
          wrote on last edited by
          #4

          Thanks @soroush. It worked perfectly.

          Joey Dumont

          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