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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:28:48+00:00 2026-05-18T06:28:48+00:00

So, this works: .h public slots: void addMenu(QString passedName); signals: void clicked(const QString &text);

  • 0

So, this works:

.h

public slots:
void addMenu(QString passedName);

signals:
void clicked(const QString &text);

.cpp

signalMapper = new QSignalMapper(this);
signalMapper->setMapping(button, QString("passed_value"));
connect(button, SIGNAL(clicked()), signalMapper, SLOT(map()));
connect(signalMapper, SIGNAL(mapped(QString)), this, SLOT(addMenu(QString)));

Now, I am trying to pass a QMap < QString, QString > through to addMenu instead of just a QString, but I get the error: no matching function for call to ‘QSignalMapper::setMapping’. Do I need to create a typeDef or something?

.h

public slots:
void addMenu(QMap < QString, QString > map);

signals:
void clicked(const QMap < QString, QString > &map);

.cpp

//map is defined above

signalMapper = new QSignalMapper(this);
signalMapper->setMapping(button, map);
connect(button, SIGNAL(clicked()), signalMapper, SLOT(map()));
connect(signalMapper, SIGNAL(mapped(QObject*)), this, SLOT(addMenu(QMap < QString, QString >)));

EDIT: I also tried adding a typeDef, but still getting same error.

.h

public:
typedef QMap < QString, QString > passedMapType;

public slots:
void addMenu(passedMapType map);

signals:
void clicked(passedMapType map);

.cpp

passedMapType passedMap;
passedMap.insert(QString("key"), QString("value"));

signalMapper = new QSignalMapper(this);
signalMapper->setMapping(button, passedMap);
connect(button, SIGNAL(clicked()), signalMapper, SLOT(map()));
connect(signalMapper, SIGNAL(mapped(QObject*)), this, SLOT(addMenu(passedMapType));

....

addMenu(passedMapType passedMap) {

}
  • 1 1 Answer
  • 2 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-18T06:28:48+00:00Added an answer on May 18, 2026 at 6:28 am

    “Now, I am trying to pass a QMap < QString, QString > through to addMenu instead of just a QString, but I get the error: no matching function for call to ‘QSignalMapper::setMapping’.”

    That’s not a general signal/slot or macro expansion problem, but a limitation of QSignalMapper. You can’t pass a QMap to setMapping, only int, QString, QWidget* and QObject*. See the QSignalMapper documentation.

    connect(signalMapper, SIGNAL(mapped(QObject*)), this, SLOT(addMenu(passedMapType));
    

    That wouldn’t work either, because the signatures are incompatible: QObject* vs. QMap.

    What I would do: Hold a QMap<QObject*,PassedMapType> in the owner of the buttons, create a slot slotClicked(QObject*) there, connected to the clicked() signals of the buttons, and then look up the PassedMapType object from the map, using the passed QObject*.
    Edit: added some pseudo code to illustrate it:

    QMap<QWidget*, QMap<QString, QString> > map; //member of the class
    
    //when creating the buttons:
    
    for each button b:
        signalMapper->setMapping( b, b );
        map.insert( b, someMapForThisButton );
    connect( signalMapper, SIGNAL(mapped(QWidget*)), this, SLOT(addMenuForButton(QWidget*)) );
    
    //the slot:
    void addMenuForButton(QWidget* w) {
         const QMap<QString, QString> m = map.value( w );
         create menu...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This works: [HttpPost] public ActionResult Slots(Slots slots, ICollection<int> jobNos) { if (!ModelState.IsValid) return View(new
This code works: class Test { public: Test(string name) : _name(name) {}; bool operator()()
This works to return a list of ints: public List<Integer> GetIListImpl() { return new
Is there any way to make this work in Java? public static void change(List<?
How can I add key value pairs to an array? This won't work: public
Why won't this work? public static int[] GetListOfAllDaysForMonths() { static int[] MonthDays = new
I have this piece of code that does not work: public CartaoCidadao() { InitializeComponent();
Can this method work? public String sayHello(){ return Hello.jsp?name= + laala; } I am
Trying to get this to work, with no luck: [DataMember] public Type ParameterType {
Why does this not work? Do I not understand delegate covariance correctly? public delegate

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.