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 3845450
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:14:47+00:00 2026-05-19T16:14:47+00:00

OK, before lecturing me on the use of C-style variadic functions in C++…everything else

  • 0

OK, before lecturing me on the use of C-style variadic functions in C++…everything else has turned out to require nothing short of rewriting the Qt MOC.

What I’d like to know is whether or not you can have a “slot” in a Qt object that takes an arbitrary amount/type of arguments. The thing is that I really want to be able to generate Qt objects that have slots of an arbitrary signature. Since the MOC is incompatible with standard preprocessing and with templates, it’s not possible to do so with either direct approach. I just came up with another idea:

struct funky_base : QObject
{
  Q_OBJECT
  funky_base(QObject * o = 0);

public slots:
  virtual void the_slot(...) = 0;
};

If this is possible then, because you can make a template that is a subclass of a QObject derived object so long as you don’t declare new Qt stuff in it, I should be able to implement a derived templated type that takes the ... stuff and turns it into the appropriate, expected types.

If it is, how would I connect to it? Would this work?

connect(x, SIGNAL(someSignal(int)), y, SLOT(the_slot(...)));

If nobody’s tried anything this insane and doesn’t know off hand, yes I’ll eventually try it myself…but I am hoping someone already has existing knowledge I can tap before possibly wasting my time on it.


This question was an attempt to find a way to design a ‘catch-all’ base class for a templated object that could translate Qt signals into static signals like boost::signals2 or just basic functions. I thought if I could construct a slot that took variadic templates I could use TMP to reconstruct the parameters out of the va_args. The answer to the problem was pretty much exactly that but cuts in BEFORE the slot gets called by the qt mechanism. The first installment of an article series on how to make the whole thing showed how I solved this part of the problem:

http://crazyeddiecpp.blogspot.com/2011/01/quest-for-sane-signals-in-qt-step-1.html

That’s my old blog location. New one’s in my profile if you want to see other weird sh1t.

  • 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-19T16:14:48+00:00Added an answer on May 19, 2026 at 4:14 pm

    Apparently people keep thinking this question is still in need of answer because several weeks after I asked it and then answered it myself, people are still posting their responses. So I guess I have to make it explicitly an answer instead of both in the question itself and the first comment for it:

    You can’t use a variadic function as a signal or slot in Qt.

    I spent a lot of time and effort not only solving the problem and sharing it, but explaining HOW the problem was solved. Please consider reading, you might even learn something new.

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

Sidebar

Related Questions

Before moving on to use SVN, I used to manage my project by simply
Before I upgraded to Firefox 3 I used to constantly use the View Source
i worked in PHP before and used to use window.location function with javascript function,
This has happenned before and I can't remember how I solved it. I renamed
Before you answer this I have never developed anything popular enough to attain high
Before I start, I know there is this post and it doesn't answer my
Before I do this I figured I would ask if it was the best
Before I jump headlong into C#... I've always felt that C, or maybe C++,
Before, I have found the Cost in the execution plan to be a good
Before anyone suggests scrapping the table tags altogether, I'm just modifying this part of

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.