Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It does make a lot of sense. I assume <a href="http://doc.qt.io/qt-5/qsignalmapper.html" rel="nofollow"><code>QSignalMapper</code></a> is not what you want. If your functions don't have arguments, maybe something like this is enough:</p> <pre><code>class SlotForwarder : public QObject { Q_OBJECT public: typedef void (*Function)(); // or whatever. I never get this syntax right... SlotForwarder(Function function, QObject* parent = 0) : QObject(parent) , m_fptr(function) {} public slots: void forward() { m_fptr(); } private: Function m_fptr; }; </code></pre> <p>Create one for each function you want to encapsulate and connect to the <code>forward</code> as usual. </p> <hr> <p>Now, if they <em>do</em> have arguments, maybe this Qt Quarterly article might be of assistance.</p> <p><a href="http://doc.qt.nokia.com/qq/qq16-dynamicqobject.html" rel="nofollow"><strong>Dynamic Signals and Slots</strong> by Eskil A. Blomfeldt</a></p> <p>The technique involves reimplementing the <code>qt_metacall</code> method yourself. The method has this signature:</p> <pre><code>int QObject::qt_metacall(QMetaObject::Call call, int id, void **arguments) </code></pre> <p><strong>Call</strong> is the kind of metacall: slot, signal, property read or write, etc. Every slot has an <strong>id</strong>. The parameters are packed (by value or as pointers) inside the <strong>arguments</strong> array. Reading the code that the moc generates is a good way to understand how it all works.</p> <p>Data about raw function signatures is available only during compile time, but slots are resolved at runtime. Because of that mismatch, you will need to wrap the functions into a template adapter type that presents a constant interface to your implementation of <code>qt_metacall</code> and converts the <code>arguments</code> array into something the function can understand (cf. Python <a href="http://docs.python.org/tutorial/controlflow.html#unpacking-argument-lists" rel="nofollow"><em>unpack</em></a> operator). <a href="http://www.boost.org/doc/libs/1_46_1/doc/html/signals.html" rel="nofollow">Boost.Signals</a> does that kind of <a href="http://svn.boost.org/svn/boost/trunk/boost/signals/signal_template.hpp" rel="nofollow">template hackery</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload