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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:29:36+00:00 2026-05-27T11:29:36+00:00

When I try to pass what appears to be a reference to my QPixmap

  • 0

When I try to pass what appears to be a reference to my QPixmap, I get an error:

 error: no matching function for call to ‘QGraphicsScene::addItem(QGraphicsPixmapItem (&)(QPixmap))’

The problem is that I don’t know where this reference is coming from, though I’m guessing it’s coming from the iterator.

void MainWindow::addItems(std::map<std::string, QString> * items)
{
    std::map<std::string, QString>::const_iterator current;

    for(current = items->begin(); current != items->end(); ++current)
    {
        QString cur = current->second;
        QGraphicsPixmapItem item(QPixmap(cur));
        _scene->addItem(item);

    }

}

If that’s the case, is there a way to de-reference the iterator? Otherwise, what is it that I’m doing wrong?

The code which calls it

int main(int argc, char *argv[])
{
    std::map<std::string, QString> * items;

    items->insert(std::pair<std::string, QString>("ozone", ":/images/ozone_sprite.png"));

    QApplication a(argc, argv);
    MainWindow window;
    window.addItems(items);
    window.show();

    delete items;

    return a.exec();
}
  • 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-27T11:29:37+00:00Added an answer on May 27, 2026 at 11:29 am

    You’ve fallen foul of what’s known as C++’s ‘most vexing parse’. Specifically, this:

    QGraphicsPixmapItem item(QPixmap(cur));
    

    declares a function called item that takes a single parameter of type QPixmap and returns a QGraphicsPixmapItem. To fix this, write:

    QPixmap temp(cur);
    QGraphicsPixmapItem item(temp);
    

    See here:

    http://en.wikipedia.org/wiki/Most_vexing_parse

    As far as the error goes, note that you’re trying to call addItem with an argument of type QGraphicsPixmapItem (&)(QPixmap) – that is, reference to a function taking a QPixmap and returning a QGraphicsPixmapItem (which is the type of the expression item).

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

Sidebar

Related Questions

I'm working on a program where I try to pass parameters by reference. I'm
I have a get-parameter with name controller . When I try to pass it
Try loading this normal .jpg file in Internet Explorer 6.0. I get an error
What is the difference between ',' and 'as' in except statements, eg: try: pass
If you try to pass the username/password to OpenVPN from a file via the
My compiler behaves oddly when I try to pass a fixed-size array to a
Given the email address: Jim <jim@example.com> If I try to pass this to MailAddress
I'm using the Facebook API Graph (C# & ASP.NET) to try to dynamically post
If I try to pass a URL to curl that contains brackets, it fails
In SQLAlchemy, it appears I'm supposed to pass an expression to filter() in certain

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.