Important: Please read the Qt Code of Conduct -

QT Signals and Templates help!!

  • hi, guyz im trying to create a library with a set of parallel SSE x.x optimized functions for some heavy loops, since i wanna make the library very integrated to QT, containers + signals and slots are important to me here.

    the ovbious case here is that all my function inside that class are nested templates using QVector/QList/QLinkedList. for example
    class my_example_class : public QObject

    template <class T>
    QVector<T> *myheavyloopfunction(QVector<T> &MyObject, + some other object for control){
    heavy loop ....

    template <class T>
    QList<T> *myheavyloopfunction(QList<T> &MyObject, + some other object for control){
    heavy loop ....

    void myheaveloopfunctionSIGNAL(??); this is my issue

    public slot:
    void myheaveloopfunctionSLOT(??); here too

    since im working with sse and prefecth in other parts of the code i want to provide aligned types with the library instead of using standard types to make sure the data is properly aligned to 16 bits or else my prefectch can go havoc with cache misses. for example
    typedef float a_float32 attribute((aligned(16));
    and the same with ints and uints ofc and other type of data with aligment, so templates and overload allow me to avoid the tedious job of writing N functions for every type.

    i would like the idea of passing a container with a template directly in the slots and signals to avoid the user of the library to link a signal for every possible type of data that can fill those containers, especially since my types are usable by QT without casting or much casting so far(need more test), so they just bother in process the result container like you normally do in QT containers

    so is this currently possible??

    im a newbie in qt4, maybe is just me paying the noobness

    thx in advance

    rafael castillo

    note the "" is because the forum eat my < T >

    [edit: syntax highlighting / Denis Kormalev]

  • @jrch2k10, edit your post and use the code markup, so it's better to read and you don't need to deal with < or > ;)

  • HI, Is there a solution for this problem? I'm facing something similar and I could use your help on this. Maybe you could point me towards a good manual for combining Qt4 or Qt5 with templates, specifically templated signals and slots.

    Thanks in advance,

  • Moderators


    Unfortunately it is currently impossible to create templated QObjects, so you can't create templated signals and slots.

    Qt's engineers are investigating this feature (see ), but nothing conclusive has come of it yet.

Log in to reply