Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6947329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:40:47+00:00 2026-05-27T13:40:47+00:00

This is a long shot but, having come across a constrain in a form

  • 0

This is a long shot but, having come across a constrain in a form of a qt’s signals, slots being unable to be templatized, I’m just thinking of replacing them with boost signals, would that be viable option?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:40:48+00:00Added an answer on May 27, 2026 at 1:40 pm

    You are not forced to use qt’s signals and slots. From Using Qt with 3rd Party Signals and Slots:

    It is possible to use Qt with a 3rd party signal/slot mechanism. You
    can even use both mechanisms in the same project. Just add the
    following line to your qmake project (.pro) file.

    CONFIG += no_keywords
    

    It tells Qt not to define the moc keywords signals, slots, and emit,
    because these names will be used by a 3rd party library, e.g. Boost.
    Then to continue using Qt signals and slots with the no_keywords flag,
    simply replace all uses of the Qt moc keywords in your sources with
    the corresponding Qt macros Q_SIGNALS (or Q_SIGNAL), Q_SLOTS (or
    Q_SLOT), and Q_EMIT.

    There is a complete explanation of how to connect boost signals to qt signals.


    I found this adapter somewhere on the net, but no idea where:

    #ifndef _QT_2_FUNC_3_H_
    #define _QT_2_FUNC_3_H_
    
    #include <iostream>
    
    #include <boost/function.hpp>
    #include <boost/type_traits.hpp>
    
    #include <QObject>
    
    #include <libQtSignalAdapters/QtConnDefault.h>
    
    using namespace boost;
    
    namespace QtSignalAdapters
    {
    
    /**
    * \cond
    */
    template<typename SIGNATURE>
    class Qt2FuncSlot3
    {
    public:
        typedef function<SIGNATURE> FuncType;
        typedef typename function_traits<SIGNATURE>::arg1_type ParmType1;
        typedef typename function_traits<SIGNATURE>::arg2_type ParmType2;
        typedef typename function_traits<SIGNATURE>::arg3_type ParmType3;
    
        Qt2FuncSlot3(const FuncType& func) :
            func_(func)
        {
        }
    
        void call(QObject* sender, void **arguments)
        {
            ParmType1* a1 = reinterpret_cast<ParmType1*>(arguments[1]);
            ParmType2* a2 = reinterpret_cast<ParmType2*>(arguments[2]);
            ParmType3* a3 = reinterpret_cast<ParmType3*>(arguments[3]);
            if ( func_ )
                func_(*a1,*a2, *a3);
        }
    
    private:
        FuncType func_;
    };
    /**
    * \endcond
    */
    
    template<typename SIGNATURE>
    class Qt2Func3 : public QObject, public QtConnDefault
    {
    public:
        typedef function<SIGNATURE> FuncType;
        typedef typename function_traits<SIGNATURE>::arg1_type ParmType;
    
        Qt2Func3(QObject* qobject, int signalIdx, const FuncType& func,
                bool initiallyConnected=true) :
            QObject(qobject),
            QtConnDefault(qobject, signalIdx),
            func_(func)
        {
            //
            // Get the next usable slot ID on this...
            //
            slotIdx_ = metaObject()->methodCount();
    
            //
            // Create a slot to handle invoking the boost::function object.
            //
            slot_ = new Qt2FuncSlot3<SIGNATURE>(func);
    
            if ( initiallyConnected )
                connect();
        }
    
        ~Qt2Func3()
        {
            delete slot_;
        }
    
        int qt_metacall(QMetaObject::Call c, int id, void **arguments)
        {
            id = QObject::qt_metacall(c, id, arguments);
            if ( id < 0 || c != QMetaObject::InvokeMetaMethod )
                return id;
    
            slot_->call(sender(), arguments);
            return -1;
        }
    
        void connect()
        {
            connect_();
        }
    
        void disconnect()
        {
            disconnect_();
        }
    
    private:
        void connect_()
        {
            connected_ =
                QMetaObject::connect(qobject_, signalIdx_, this, slotIdx_);
        }
    
        void disconnect_()
        {
            connected_ =
                !QMetaObject::disconnect(qobject_, signalIdx_, this, slotIdx_);
        }
    
    
        FuncType func_;
        Qt2FuncSlot3<SIGNATURE>* slot_;
    };
    
    }
    
    #endif
    

    So, basically you have to reimplement qt_metacall function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be a long shot, but I'm having a bug that I'm fairly
I know this is a long shot but, I've been having trouble with a
This is probably a long shot, but I have vague sense I ran across
I know this is a long shot - but is there any way at
This looks like a long shot, but does anyone know of a way to:
It might be a long shot posting this question here but we will see.
This is a bit of a long shot, but if anyone can figure it
I know this might be a long shot, but here it goes. I have
I know this one is going to be a long-shot, but I thought I'd
I know this is a long shot but is there any way of getting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.