Forum: GNU Radio SWIG and QT (QT4_WRAP_CPP issues)

196dd23ea5fa1e7f41e571b60e7c1801?d=identicon&s=25 Stefan Wunsch (Guest)
on 2014-06-19 23:32
(Received via mailing list)
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:

};
0817fa933c74eec9b3fcf3a04e16f418?d=identicon&s=25 Sylvain Munaut (Guest)
on 2014-06-20 00:06
(Received via mailing list)
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
196dd23ea5fa1e7f41e571b60e7c1801?d=identicon&s=25 Stefan Wunsch (Guest)
on 2014-06-20 00:24
(Received via mailing list)
Sylvain solved it in a sec ;) 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:
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.