SWIG and QT (QT4_WRAP_CPP issues)

Hi!

I try to add a QT GUI to my OOT module (gr-radar). I have some issues
with including the QT stuff in cmake and swig.

The problem is this error:

/gr-radar/swig/…/lib/range_velocity_diagram.h:45: Error: Syntax

error in input(3).

make[2]: *** [swig/radar_swigPYTHON_wrap.cxx] Error 1

make[1]: *** [swig/CMakeFiles/pygen_swig_9a820.dir/all] Error 2

The line 45 refers to

public slots:

Whole class definition is appended.[0]

If I build my module without ‘public slots:’ line but WITH the Q_OBJECT
line everything runs fine and I get a new QT window. So I suppose that
the additional class range_velocity_diagram is included correctly in
cmake and swig. Also I think the Q_OBJECT macro is accepted by cmake and
swig.

I have looked at gr-qtgui and added QT4_WRAP_CPP to get the Q_OBJECT
macro running. My changes in CMakeLists.txt (lib directory):

set(QTGUI_MOC_HEADERS range_velocity_diagram.h)
QT4_WRAP_CPP(QTGUI_MOC_OUTFILES ${QTGUI_MOC_HEADERS})
add_library(gnuradio-radar SHARED ${radar_sources}
${QTGUI_MOC_OUTFILES})

Do I need to add more to get swig running with the QT slots and signals?
I am correct with the assumption that cmake and swig accepts the
Q_OBJECT macro?

Best regards
Stefan

[0] Class definition range_velocity_diagram
class range_velocity_diagram : public QWidget
{
Q_OBJECT;

public:
range_velocity_diagram();
~range_velocity_diagram();

private:
QwtPlot* d_plot;
QwtPlotCurve* d_curve;

public slots:

};

Hi,

Do I need to add more to get swig running with the QT slots and signals?
I am correct with the assumption that cmake and swig accepts the
Q_OBJECT macro?

Why do you even need to get those through swig ?

Last time I did a Qt block, all the Qt stuff was hidden from swig,
there was only theses in the header :


  virtual void exec_() = 0;
  virtual QWidget* qwidget() = 0;

#ifdef ENABLE_PYTHON
virtual PyObject* pyqwidget() = 0;
#else
virtual void* pyqwidget() = 0;
#endif

  QApplication *d_qApplication

and nothing more, all the rest was hidden and never went through swig.

Cheers,

Sylvain

Sylvain solved it in a sec :wink: There is no need to get the classes with
the qt stuff through swig. Solution is including the additional qt
classes only in cmake and wrap them with QT4_WRAP_CPP cause of the
Q_OBJECT macro but dont care about them in the *_swig.i file.

Am 19.06.2014 23:31, schrieb Stefan Wunsch:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs