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

  • Home
  • SEARCH
  • 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 7854067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:55:19+00:00 2026-06-02T19:55:19+00:00

My project is to create a small program which demonstrates the work of a

  • 0

My project is to create a small program which demonstrates the work of a search engine: indexing and returning result for arbitrary queries. I’ve done the work with the indexer part and now I want to improve it with indexing multiple files at once. The MainWindow class is here:

class MainWindow : public QMainWindow
{
    Q_OBJECT
    .....
private:
    Indexer * indexer;
    QStringList fileList;
    ....
    void index(QStringList list);
    void add(const QString &filename);
}

This is the implementation of add (add need to access fileList to avoid index the same files again, thus it can not be static method):

void MainWindow::add(const QString &filename)
{
    if (!fileList.contains(filename))
    {
        indexer->addDocument(filename.toStdString());
        fileList.append(filename);
        qDebug() << "Indexed" << filename;
        emit updatedList(fileList);
    }
}

The implement of index method is to receive a file lists and call add upon each file name:

void MainWindow::index(QStringList list)
{
    ....
    QtConcurrent::map(list, &MainWindow::add);
    ....
}

The error I receive when compiling these code is:

usr/include/qt4/QtCore/qtconcurrentmapkernel.h: In member function 'bool QtConcurrent::MapKernel<Iterator, MapFunctor>::runIteration(Iterator, int, void*) [with Iterator = QList<QString>::iterator, MapFunctor = QtConcurrent::MemberFunctionWrapper1<void, MainWindow, const QString&>]':
../search-engine/mainwindow.cpp:361:1:   instantiated from here
/usr/include/qt4/QtCore/qtconcurrentmapkernel.h:73:9: error: no match for call to '(QtConcurrent::MemberFunctionWrapper1<void, MainWindow, const QString&>) (QString&)'
/usr/include/qt4/QtCore/qtconcurrentfunctionwrappers.h:128:7: note: candidate is:
/usr/include/qt4/QtCore/qtconcurrentfunctionwrappers.h:138:14: note: T QtConcurrent::MemberFunctionWrapper1<T, C, U>::operator()(C&, U) [with T = void, C = MainWindow, U = const QString&]
/usr/include/qt4/QtCore/qtconcurrentfunctionwrappers.h:138:14: note:   candidate expects 2 arguments, 1 provided

I’m not really familiar with how QtConcurrent works, and the documentation doesn’t provide much details about it. I really hope that someone here can help. Thanks in advance.

  • 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-06-02T19:55:22+00:00Added an answer on June 2, 2026 at 7:55 pm

    To be able to call a pointer-to-member, you need, in addition to that functions formal arguments, an instance of that class (the this pointer that you get inside member functions).

    There are two ways to handle this: create a simple functor to wrap the call, or use a lambda.

    The functor would look like this:

    struct AddWrapper {
      MainWindow *instance;
      AddWrapper(MainWindow *w): instance(w) {}
      void operator()(QString const& data) {
        instance->add(data);
      }
    };
    

    And you’d use it like:

    AddWrapper wrap(this);
    QtConcurrent::map(list, wrap);
    

    (Careful with the lifetime of that wrapper though. You could make that more generic – you could also store a pointer-to-member in the wrapper for instance, and/or make it a template if you want to reuse that structure for other types.)

    If you have a C++11 compiler with lambdas, you can avoid all that boilerpalte:

    QtConcurrent::map(list, [this] (QString const& data) { add(data); });
    

    Note: I’m not sure how QtConcurrent::MemberFunctionWrapper1 got involved in your example, I’m not seeing it here. So there might be a generic wrapper already in Qt for this situation, but I’m not aware of it.

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

Sidebar

Related Questions

I have a project to create a program, which prevents the user from escaping
For a small project, I've to create in html/javascript (no Flash/Silverlight... it has to
I'm learning to do TDD in practice in small project. I want to create
I'm working in a project for the iPad, it is a small program and
i am making a small project which will be incorporated into larger project. basically
I've got a small Clojure program that uses the Clojure JDBC tools to create
I'm doing a small project to help my work go by faster. I currently
I'm working on a small C++ project which involves a launcher application that does
I have created a small flash CS4 project that has a few custom components
I've inherited a small project. The person before me created a native app for

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.