Results 1 to 2 of 2

Thread: QWT in QT: displaying qwt plot as widget on mainwindow

  1. #1
    Join Date
    Jun 2013
    Posts
    3
    Platforms
    Windows

    Unhappy QWT in QT: displaying qwt plot as widget on mainwindow

    Hello all,

    I have developed a code for plotting sine wave in qwt.I have made a subclass of QWT with the name of plot. I want to show this plot as widget in mainwindow. I did following in Mainwindow.cpp:
    Qt Code:
    1. dplot = new plot(this );
    2. const int margin = 4;
    3. dplot->setContentsMargins( margin, margin, margin, margin );
    4.  
    5. setCentralWidget( dplot );
    To copy to clipboard, switch view to plain text mode 
    and in Mainwindow.h I have declared the class plot like this:
    Qt Code:
    1. #include <QMainWindow>
    2.  
    3. class plot;
    4.  
    5. class MainWindow: public QMainWindow
    6. {
    7. Q_OBJECT
    8. public:
    9. MainWindow();
    10.  
    11. private Q_SLOTS:
    12.  
    13.  
    14. private:
    15.  
    16.  
    17. private:
    18. plot *dplot;
    19.  
    20. };
    To copy to clipboard, switch view to plain text mode 

    I am facing following error after compiling:

    In constructor 'MainWindow::MainWindow()':
    error: no matching function for call to 'plot:lot(MainWindow* const)'
    candidates are: plot:lot()
    plot:lot(const plot&)

    Please help me.

  2. #2
    Join Date
    Nov 2009
    Posts
    39
    Thanks
    9
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QWT in QT: displaying qwt plot as widget on mainwindow

    In your derived class, you need a constructor that take a QWidget pointer argument. This constructor needs to call with the QwtPlot constructor with the same pointer. Something like

    Qt Code:
    1. plot::plot(QWidget* parent) : QwtPlot(parent) {
    2.  
    3. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Displaying a eml file in a widget
    By merry in forum Qt Programming
    Replies: 2
    Last Post: 29th August 2013, 18:36
  2. Add widget to mainwindow
    By K4ELO in forum Qt Programming
    Replies: 10
    Last Post: 19th February 2013, 23:12
  3. Replies: 0
    Last Post: 6th November 2011, 10:22
  4. Displaying plot in main QT window
    By Gavin Harper in forum Qwt
    Replies: 1
    Last Post: 23rd August 2010, 14:59
  5. Replies: 10
    Last Post: 29th May 2010, 19:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.