June 30, 2012

Pavel Mazniker Pavel Mazniker
Lab Rat
175 posts

Slot Declaration rare problem to resolve[SOLVED]

 

Hi.

I am finishing to code custom MainWindow class:

mainwindow.h file:

  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3. #include <QMainWindow>
  4. #include <QFileDialog>
  5. #include "qwt_plot_canvas.h"
  6. #include "lib/wfdb.h"
  7. #include "lib/ecgmap.h"
  8. #include "curvedata.h"
  9. #include "qwt_plot_grid.h"
  10. //temporary
  11. #include <QDebug>
  12.  
  13. namespace Ui {
  14. class MainWindow;
  15. }
  16.  
  17. class MainWindow : public QMainWindow
  18. {
  19.     Q_OBJECT
  20. public:
  21.     explicit MainWindow(QWidget *parent = 0);
  22.     ~MainWindow();
  23. private:
  24.     void init_plot();
  25.     void process();
  26. public slots:
  27.     void LoadData();
  28. private:
  29.     Ui::MainWindow *ui;
  30.     CurveData *cvData_in;
  31.     CurveData *cvData_out;
  32.     QwtPlotCurve *qwtpltcrv_in;
  33.     QwtPlotCurve *qwtpltcrv_out;
  34.     int lp[LP_SIZE];
  35.     char *db_name;
  36. };
  37.  
  38. #endif // MAINWINDOW_H

the slot LoadData is definde in mainwindow.cpp file as:

void MainWindow::LoadData()
{ …
}

as well as another functions:

but when compiling as usual using
Qt 4.8.0 for Desktop – MinGW ( Qt SDK ), Mingw as GCC for windows targets

Compile output contains next notification about slot declaration:

In file included from main.cpp:2:
mainwindow.h:26: error: expected ‘:’ before ‘slots’
mainwindow.h:27: error: expected primary-expression before ‘void’
mainwindow.h:27: error: ISO C++ forbids declaration of ‘slots’ with no type
mainwindow.h:27: error: expected ‘;’ before ‘void’

Would somebody help me / point out why such problem?
How to resolve and to get succesfull compilation?

Thnaks in advance,
Paul

2 replies

June 30, 2012

DerManu DerManu
Robot Herder
451 posts

What happens when you don’t use the public slots notation, but Q_SLOTS?
does qmake run successfully?

June 30, 2012

Pavel Mazniker Pavel Mazniker
Lab Rat
175 posts

What happens when you don’t use the public slots notation, but Q_SLOTS?
does qmake run successfully?

—Thank you.The code after replacing public slots notation to Q_SLOTS compiled and run successfully.That is because of includes of QWT in the project I guess with high likelihood and having a reason.
Solved.

 
  ‹‹ Harmattan screen at start of app      Is this DBus signal connection code correct? ››

You must log in to post a reply. Not a member yet? Register here!