Hi,

Is it possible to get your slots to call other functions from other classes?

I want to have my main qwidget's buttons call on a class I made that plots some QWTplots. This is what I'm working on now, but I am afraid I am going about the slot implementation the wrong way

Qt Code:
  1. class myPlot : public QwtPlot
  2. {
  3. ...
  4. myPlot(){}
  5. void loadFile( char * fn )
  6. {
  7. //a function that opens a file...
  8. }
  9. void plot( double st, double end )
  10. {
  11. //loads the data and assigns it to a curve...
  12. }
  13. };
  14. class myCanvas : public QWidget
  15. {
  16. Q_OBJECT
  17. public:
  18. myCanvas (QWidget * parent = 0);
  19. public Q_SLOTS:
  20. void enterFile();
  21. void addFile();
  22. void makePlot();
  23. };
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. myCanvas::myCanvas(QWidget *parent):QWidget(parent)
  2. {
  3. ....
  4. myPlot *plot = new myPlot(); //is this even close to right?
  5.  
  6. connect(pushbutton, SIGNAL(clicked()), this, SLOT(enterFile()));
  7. connect(pushbutton, SIGNAL(clicked()), this, SLOT(addFile()));
  8. connect(pushbutton, SIGNAL(clicked()), this, SLOT(makePlot()));
  9. ....
  10. }
  11.  
  12. void myCanvas::enterFile()
  13. {
  14. QString theText = lineedit->text(); ///this works
  15. FileName = qstrdup( theText.toLatin1() );
  16. }
  17. void myCanvas::addFile()
  18. {
  19. plot->loadFile(FileName); //error plot undeclared identifier
  20. }
  21. void myCanvas::slotButtonPlots()
  22. {
  23. myPlot::plot(1264377600, 1288974375.51);
  24. //error: illegal call of non-static member function
  25. // something like this maybe?
  26. }
To copy to clipboard, switch view to plain text mode 


Any ideas how I can call these these myPlot functions with myCanvas, or is that impossible?

Do I have to make new functions in myCanvas in order for the slots to work?

Thanks a lot!