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 - Plotting Problem
QtWS25 Last Chance

Qwt - Plotting Problem

Scheduled Pinned Locked Moved General and Desktop
19 Posts 5 Posters 12.2k 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.
  • K Offline
    K Offline
    kingsta
    wrote on 9 Apr 2013, 12:31 last edited by
    #7

    Yes setSamples() works. How can i use setData()?

    What do you think about the curve? I think something is wrong.

    Photo Link: http://b1304.hizliresim.com/18/9/lx94g.jpg

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 9 Apr 2013, 12:59 last edited by
      #8

      Like the error is reporting there is no setData that takes two double arrays and an int.

      "That's":http://qwt.sourceforge.net/class_qwt_plot_series_item.html#adba072515f7c71c923985882129878c4 the only setData I know of

      Can't really comment on the photo, I don't know how you setup your plot. Can you share the code ?

      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
      • K Offline
        K Offline
        kingsta
        wrote on 9 Apr 2013, 13:06 last edited by
        #9

        Okey. Here my codes.

        plot.h
        @#ifndef PLOT_H
        #define PLOT_H

        #include <QWidget>

        #include <qwt_plot.h>
        #include <qwt_plot_curve.h>

        class Plot : public QwtPlot
        {
        Q_OBJECT
        public:
        Plot(QWidget* = NULL);

        //signals:

        //public slots:

        };

        #endif // PLOT_H
        @

        plot.cpp
        @#include "plot.h"

        Plot::Plot(QWidget *parent) :
        QwtPlot(parent)
        {

        double a[5] = { 1, -2, 30, -40, 5};
        double b[5] = { -13, 20, -30, 40, -50};

        QwtPlotCurve *curve1 = new QwtPlotCurve(QString("Curve 1"));
        QwtPlotCurve *curve2 = new QwtPlotCurve(QString("Curve 2"));

        curve1->setPen(QPen(Qt::black, 1));
        curve2->setPen(QPen(Qt::red, 1));

        curve1->attach(this);
        curve2->attach(this);

        curve1->setRawSamples(a, b, 5);

        setTitle("Wave Curve");
        setAxisTitle(QwtPlot::xBottom, "Seconds");
        setAxisScale(QwtPlot::xBottom, 0, 1);
        setAxisTitle(QwtPlot::yLeft, "Waves");
        setAxisScale(QwtPlot::yLeft, -100, 100);
        
        setCanvasBackground(Qt::white);
        
        replot();
        

        }@

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kingsta
          wrote on 13 Apr 2013, 07:25 last edited by
          #10

          I add some codes to pro file, and I got "The program has unexpectedly finished." error when I try to compile. How to fix this?

          @INCLUDEPATH += C:/QtSdk/qwt-6.0.0-rc4/src
          win32:LIBS += C:/QtSdk/qwt-6.0.0-rc4/lib/libqwtd.a
          win32:QMAKE_POST_LINK = copy /Y C:\QtSdk\qwt-6.0.0-rc4\lib\qwtd.dll $(DESTDIR)
          CONFIG +=qwt@

          1 Reply Last reply
          0
          • K Offline
            K Offline
            koahnig
            wrote on 13 Apr 2013, 09:35 last edited by
            #11

            Which did finish unexpectedly?
            Probably you have rerun qmake.

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply
            0
            • F Offline
              F Offline
              franku
              wrote on 13 Apr 2013, 09:48 last edited by
              #12

              You are providing temporary objects a und b to curve1->setRawSamples(a, b, 5); They only live inside the constructur. Probably this could result into you problem.

              This, Jen, is the internet.

              1 Reply Last reply
              0
              • K Offline
                K Offline
                kingsta
                wrote on 13 Apr 2013, 10:02 last edited by
                #13

                [quote author="koahnig" date="1365845732"]Which did finish unexpectedly?
                Probably you have rerun qmake. [/quote]

                I click the run button and I show that error message. Program.exe didn't open. How can i rerun qmake?

                [quote author="franku" date="1365846514"]You are providing temporary objects a und b to curve1->setRawSamples(a, b, 5); They only live inside the constructur. Probably this could result into you problem. [/quote]

                If I understand to you truly; I declare a and b variables in plot.h, a and b take values in constructor plot.cpp. Problem wasn't fixed.

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  koahnig
                  wrote on 13 Apr 2013, 10:20 last edited by
                  #14

                  [quote author="kingsta" date="1365847361"][quote author="koahnig" date="1365845732"]Which did finish unexpectedly?
                  Probably you have rerun qmake. [/quote]

                  I click the run button and I show that error message. Program.exe didn't open. How can i rerun qmake?
                  [/quote]

                  On left side there is the list with projects. Go to the project in question and press right mouse button. An entry with "run qmake" is there.

                  BTW if the problem from before still exists, this will not cure the problem. franku is right that the temporary declaration is the problem.

                  @
                  static double a[5] = { 1, -2, 30, -40, 5};
                  static double b[5] = { -13, 20, -30, 40, -50};
                  @

                  will solve your problem for the time being in a very crude way.
                  Personally, I would recommend that you get a bit more familiarization with "C++ and pointers.":http://bit.ly/16TMY9C

                  Vote the answer(s) that helped you to solve your issue(s)

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    kingsta
                    wrote on 17 Apr 2013, 08:26 last edited by
                    #15

                    [quote author="koahnig" date="1365848437"][quote author="kingsta" date="1365847361"][quote author="koahnig" date="1365845732"]Which did finish unexpectedly?
                    Probably you have rerun qmake. [/quote]

                    I click the run button and I show that error message. Program.exe didn't open. How can i rerun qmake?
                    [/quote]

                    On left side there is the list with projects. Go to the project in question and press right mouse button. An entry with "run qmake" is there.

                    BTW if the problem from before still exists, this will not cure the problem. franku is right that the temporary declaration is the problem.

                    @
                    static double a[5] = { 1, -2, 30, -40, 5};
                    static double b[5] = { -13, 20, -30, 40, -50};
                    @

                    will solve your problem for the time being in a very crude way.
                    Personally, I would recommend that you get a bit more familiarization with "C++ and pointers.":http://bit.ly/16TMY9C [/quote]

                    I use static variable and there is a kind of weird problem.

                    There is no curve on display.
                    @
                    static double a1[] = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
                    static double b1[] = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100};

                    curve2->setRawSamples(a1, b1, 10);
                    @

                    Weird curve.
                    @
                    static double a1[] = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
                    static double b1[] = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100};

                    curve2->setRawSamples(a1, b1, 11); // If I write a number is greater than 10, Display a wrong curve again
                    @
                    Qt plot the curve which is not my wish again.

                    I add the pro file this code to compile this files. I know Its a bad thing.
                    @include( examples.pri )@

                    Examples.pri, exaples.pro files are in Qwt Examples.
                    Examples.pri: http://svn.code.sf.net/p/qwt/code/branches/qwt-6.0/examples/examples.pri

                    Now I cant add "public slots" in header file.

                    my mainwindow.h file;
                    @#include <QMainWindow>

                    class QStandardItemModel;
                    class QAction;
                    class QMenu;

                    namespace Ui {
                    class MainWindow;
                    }

                    class MainWindow : public QMainWindow
                    {
                    Q_OBJECT

                    public:
                    explicit MainWindow(QWidget *parent = 0);
                    ~MainWindow();
                    enum Mode {ImportingMode, AnalyzingeMode, FilteringMode};

                    public slots: // line 23
                    void importData(); // line 24
                    ...
                    @

                    Line 23: error: expected ':' before 'slots'
                    Line 24: error: expected primary-expression before 'void'
                    Line 24: error: ISO C++ forbids declaration of 'slots' with no type
                    Line 24: error: expected ';' before 'void'

                    I create plot.h, plot.cpp as you say
                    What should I do?

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      kingsta
                      wrote on 20 Apr 2013, 09:47 last edited by
                      #16

                      Does anyone know how to use public slots when adding qwt libraries?

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 22 Apr 2013, 07:16 last edited by
                        #17

                        example.pri is not meant to be included like you do it.

                        I think it's screwing up your own project.

                        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
                        • K Offline
                          K Offline
                          kingsta
                          wrote on 28 Apr 2013, 09:17 last edited by
                          #18

                          [quote author="SGaist" date="1366615003"]example.pri is not meant to be included like you do it.

                          I think it's screwing up your own project.

                          [/quote]

                          You right. I should do by different way.

                          We use Q_SLOTS when we add some 3rd party library. It works.
                          @public Q_SLOTS:@

                          I have a problem again. I can't remove the curve on screen. I write that code. When I run the program, Program is crushed.
                          header file
                          @Plot plot1;@

                          Source file
                          @plot1->detachItems();@

                          How can i remove only the curve?

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on 28 Apr 2013, 22:24 last edited by
                            #19

                            Plot plot1 <= instance of Plot

                            plot1->detachItems() <= pointer to instance of Plot

                            Got a NULL pointer ?

                            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

                            16/19

                            20 Apr 2013, 09:47

                            • Login

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