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. [qwt] Plot is not displayed when using QwtPlot
Forum Updated to NodeBB v4.3 + New Features

[qwt] Plot is not displayed when using QwtPlot

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 3.0k 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
    silviutp
    wrote on last edited by
    #1

    I want to use qwt to draw plots and I'm starting with some easy examples like the one bellow.

    @ QwtPlot plot = new QwtPlot();
    QwtPlotCurve
    f = new QwtPlotCurve("Line");
    double xdata[10], ydata[10] ;
    for (int i = 0; i< 10; i++) {
    xdata[i] = i+1;
    ydata[i] = (i+1)*10;
    }
    f->setRawSamples(xdata,ydata,10);
    f->attach(plot);
    plot->replot();@

    The problem is that nothing happens, no window displayed.....

    I use Qt 5.1.0 with mingw 4.8 and qwt 6.1 compiled also with mingw 4.8 on Windows 7 x86.

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

      Hi,

      Do you call show on your plot somewhere ?
      Do you put it in a layout in another widget ?

      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
        silviutp
        wrote on last edited by
        #3

        Hi,

        I use that code inside a function used in a QApplication;
        I have also tried to use it main function, like this:
        @
        int main(int argc, char *argv[])
        {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
        QwtPlot plot = new QwtPlot();
        QwtPlotCurve
        f = new QwtPlotCurve("Line");
        double xdata[10], ydata[10] ;
        for (int i = 0; i< 10; i++) {
        xdata[i] = i+1;
        ydata[i] = (i+1)*10;
        }
        f->setRawSamples(xdata,ydata,10);
        f->attach(plot);
        plot->replot();

        return a.exec&#40;&#41;;
        

        }@

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

          You still don't call

          @plot->show();@

          You're also introducing a memory leak not deleting your plot after a.exec();

          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
            silviutp
            wrote on last edited by
            #5

            Thank you, that was the problem..
            Do I have to manually destroy the plot, doesn't this happen when I click the Close button (in the plot widget) ?

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

              It only happens if you have Qt::WA_DeleteOnClose set on your widget

              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