Results 1 to 3 of 3

Thread: Not able to connect to qwtplotWidget

  1. #1
    Join Date
    Mar 2008
    Posts
    46
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Question Not able to connect to qwtplotWidget

    Hi guy's.
    I am trying to run a program in Qt4.3.3 with VS2005. But there is a problem.
    I am using qwtplot widget on a .ui form QDialog and a pushButton called Draw on it.I only want to change the Title and the Scale of the Plot Widget.The project compiles with out an error and the form which i created is displayed but the scale and the Title don't change. The default qwtplot widget s only displayed. Here is the code pls see if you can help me.

    ----newplot.cpp------

    Qt Code:
    1. #include "newplot.h"
    2. #include <QtGui>
    3. #include "qwt_plot.h"
    4. #include "qwt_scale_widget.h"
    5. newplot::newplot(QWidget *parent)
    6. : QDialog(parent)
    7. {
    8. setupUi(this);
    9. QwtPlot *myPlot;
    10. connect(drawButton, SIGNAL(clicked()), this, SLOT(draw()));
    11. }
    12. void newplot::on_drawButton_clicked()
    13. {
    14. }
    15. void newplot::draw()
    16. {
    17. QwtText title( "Two Curves" );
    18. myPlot = new QwtPlot();
    19.  
    20. myPlot->setAxisTitle(QwtPlot::xBottom, "Time/seconds");
    21. myPlot->setAxisScale(QwtPlot::xBottom, 0, 100);
    22.  
    23. myPlot->setAxisTitle(QwtPlot::yLeft, "Values");
    24. myPlot->setAxisScale(QwtPlot::yLeft, 0, 50);
    25. myPlot->replot();
    26. }
    To copy to clipboard, switch view to plain text mode 

    -----------newplot.h----------

    Qt Code:
    1. #ifndef NEWPLOT_H
    2. #define NEWPLOT_H
    3. #include <QtGui/QDialog>
    4. #include "ui_newplot.h"
    5. #include "qwt_plot.h"
    6.  
    7. class newplot : public QDialog, public Ui::newplot
    8. {
    9. Q_OBJECT
    10.  
    11. public:
    12. newplot(QWidget *parent = 0);
    13. private slots:
    14. void on_drawButton_clicked();
    15. void draw();
    16. };
    17. #endif // NEWPLOT_H
    To copy to clipboard, switch view to plain text mode 

    ------------main.cpp----------

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "newplot.h"
    3. #include "ui_newplot.h"
    4. #include "qwt_plot.h"
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication app(argc, argv);
    9. //Ui::newplotClass ui;
    10. newplot *dialog = new newplot;
    11. //ui.setupUi(dialog);
    12. dialog->show();
    13. return app.exec();
    14. }
    To copy to clipboard, switch view to plain text mode 

    Hey i am sorry i wanted to attach the .ui file but its a big file and i am allowed to upload a file size of max 19.5 kb. So i din attach it.

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Not able to connect to qwtplotWidget

    newplot::draw creates an invisible new plot widget each time it is called.

    Uwe

  3. #3
    Join Date
    Mar 2008
    Posts
    46
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Not able to connect to qwtplotWidget

    Hey Uwe thank you for the time. How do i modify the program to work with the .Ui form i created. I am not able to connect the code with the Form which i created.

Similar Threads

  1. Can I use arbitrary constants in a connect()?
    By WinchellChung in forum Newbie
    Replies: 3
    Last Post: 18th February 2008, 22:48
  2. qobject connect questions
    By VireX in forum Newbie
    Replies: 5
    Last Post: 20th May 2007, 09:04
  3. Replies: 5
    Last Post: 28th August 2006, 14:36
  4. connect to sql server
    By raphaelf in forum Qt Programming
    Replies: 15
    Last Post: 27th February 2006, 18:06

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.