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. Qwt plot inside QDialog inside QWidget?
Forum Updated to NodeBB v4.3 + New Features

Qwt plot inside QDialog inside QWidget?

Scheduled Pinned Locked Moved Solved 3rd Party Software
qwtqdialogqwidgetparent
2 Posts 1 Posters 891 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.
  • P Offline
    P Offline
    pauledd
    wrote on 7 Mar 2020, 15:51 last edited by
    #1

    Hi

    I do my first steps with qwt and I already stumbled upon a simple task.
    I have a MainWindow (QWidget) that contains a QPushButton which will
    open a PlotWindow (QDialog) that SHALL be filled by a Qwt Plot.
    I used a QDialog because I want the PlotWindow close if I close the MainWindow.
    The Qwt plot shall use all the space available in the PlotWindow

    // mainwindow.h
    
    #include <QWidget>
    #include <QPushButton>
    #include "plotwindow.h"
    class MainWindow : public QWidget
    {
        Q_OBJECT
    public:
        explicit MainWindow(QWidget *parent=nullptr);
    private:
        QPushButton *pushbutton;
        PlotWindow *plotWindow;
    private slots:
        void showPlotWindow();
    };
    
    // mainwindow.cpp
    
    #include "mainwindow.h"
    MainWindow::MainWindow(QWidget *parent)
        :QWidget(parent)
    {
        pushbutton = new QPushButton("PLOT",this);
        plotWindow = new PlotWindow(this);
        connect(pushbutton,&QPushButton::clicked,this,&MainWindow::showPlotWindow);
    }
    
    void MainWindow::showPlotWindow()
    {
        plotWindow->show();
    }
    
    // plotwindow.h
    
    #include <QDialog>
    #include <qwt/qwt_plot.h>
    
    
    class PlotWindow : public QDialog
    {
        Q_OBJECT
    public:
        explicit PlotWindow(QWidget *parent=nullptr);
    private:
    
    };
    
    // plotwindow.cpp
    
    #include "plotwindow.h"
    #include <qwt/qwt_text.h>
    PlotWindow::PlotWindow(QWidget *parent)
        :QDialog(parent)
    {
        QwtPlot *plot = new QwtPlot( "Test", parent );
        resize(233,222);
    }
    

    If I compile the code I get this error:

    /home/p/store/c++/qt/qwt_test/plotwindow.cpp:6: error: no matching function for call to ‘QwtPlot::QwtPlot(const char [5], QWidget*&)’
        6 |     QwtPlot *plot = new QwtPlot( "Test", parent );
          |                                                 ^
    

    Whats wrong here?

    1 Reply Last reply
    0
    • P Offline
      P Offline
      pauledd
      wrote on 7 Mar 2020, 16:06 last edited by
      #2

      ok, stupid me! I forgot to include Qwt in the *.pro file:

      ...
      CONFIG += qwt
      INCLUDEPATH +="/usr/include/qwt"
      LIBS += -L/usr/lib -lqwt
      
      1 Reply Last reply
      0

      1/2

      7 Mar 2020, 15:51

      • Login

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