'Could you tell me how to solve "No such slot listofblogs::map() in ../lab1/listofblogs.cpp:50" in QT

I added a button in each row in TableView. But, I keep getting this error when I click the button and I have no idea why. I searched many sites and Q&A, but I could not solve it. So could anyone help me?

The following code is a header file

//list of blog.h
#ifndef LISTOFBLOGS_H
#define LISTOFBLOGS_H

#include <QJsonArray>
#include <QDialog>
#include <QFont>
#include <QSignalMapper>

namespace Ui {
class listofblogs;
}

class listofblogs : public QDialog
{
    Q_OBJECT

public:
    explicit listofblogs(QWidget *parent = nullptr);
    ~listofblogs();
    void setuserID(QString userID);
    QString getuserID();

private slots:
    void on_pushButton_clicked();
    void doSomething(int row);

private:
    Ui::listofblogs *ui;
    QString UserID;
    QSignalMapper *signalMapper;
};

#endif // LISTOFBLOGS_H

Then, this is the c++ source code.

#include "listofblogs.h"
#include "ui_listofblogs.h"
#include "readandwritejson.h"
#include "blog.h"

void listofblogs::doSomething(int row){
    qDebug()<<row;
}

listofblogs::listofblogs(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::listofblogs)
{
    ui->setupUi(this);
    QFont font=ui->label_2->font();
    font.setPointSize(16);
    ui->label_2->setFont(font);
    QTableWidget *tw = ui->tableWidget;
    tw->clear();
    tw->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    QStringList columns;
    columns << "title" << "userID" << "time"<< "open content";
    QJsonArray bloglist=readbloglist();
    int row = bloglist.size();
    int col = columns.size();
    tw->setRowCount(row);
    tw->setColumnCount(col);
    for (int i = 0; i < col; ++i){
             tw->setHorizontalHeaderItem(i, new QTableWidgetItem(columns.at(i)));
    }
    signalMapper = new QSignalMapper(this);
    for( int i=0; i<row; i++ ) {
        QJsonObject temp = bloglist.at(i).toObject();
        for (int j = 0; j < col-1; j++){

            auto item = tw->model()->index(i, j);
            QString col_data = columns.at(j);
            tw->model()->setData(item, QVariant::fromValue(temp.value("blogData").toObject().value(col_data).toString()));

        }
        //make new button for this row
        auto item = tw->model()->index(i, columns.size()-1);
        QPushButton *cartButton = new QPushButton("open");
        cartButton->setMaximumWidth(50);
        tw->setIndexWidget(item, cartButton);

        connect(cartButton, SIGNAL(clicked(bool)), this, SLOT(map()));
        //connect(cartButton, &QPushButton::clicked, signalMapper, &QSignalMapper::map);
        signalMapper->setMapping(cartButton, i);
    }
    connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(doSomething(int)));
    for(int col = 0; col < columns.size(); col++) {
        tw->resizeColumnToContents(col);
    }
    tw->horizontalHeader()->setStretchLastSection(true);
    tw->setEditTriggers(QAbstractItemView::NoEditTriggers);
    tw->scrollToBottom();
    tw->verticalHeader()->hide();
    tw->setSelectionMode(QAbstractItemView::NoSelection);
    tw->resizeColumnsToContents();
}

listofblogs::~listofblogs()
{
    delete ui;
}
void listofblogs::setuserID(QString userID){
    UserID=userID;
}

QString listofblogs::getuserID(){
    return UserID;
}
void listofblogs::on_pushButton_clicked()
{
    blog *Blog;
    Blog = new blog(this);
    Blog->setuserID(UserID);
    Blog->show();
}

I can compile this code, but when I clicked a button, the following error occurs.

qt.core.qobject.connect: QObject::connect: No such slot listofblogs::map() in ../lab1/listofblogs.cpp:50
qt.core.qobject.connect: QObject::connect:  (receiver name: 'listofblogs')
qt.core.qobject.connect: QObject::connect: No such slot listofblogs::map() in ../lab1/listofblogs.cpp:50
qt.core.qobject.connect: QObject::connect:  (receiver name: 'listofblogs')
qt.core.qobject.connect: QObject::connect: No such slot listofblogs::map() in ../lab1/listofblogs.cpp:50
qt.core.qobject.connect: QObject::connect:  (receiver name: 'listofblogs')
qt.core.qobject.connect: QObject::connect: No such slot listofblogs::map() in ../lab1/listofblogs.cpp:50
qt.core.qobject.connect: QObject::connect:  (receiver name: 'listofblogs')
qt.core.qobject.connect: QObject::connect: No such slot listofblogs::map() in ../lab1/listofblogs.cpp:50
qt.core.qobject.connect: QObject::connect:  (receiver name: 'listofblogs')
qt.core.qobject.connect: QObject::connect: No such slot listofblogs::map() in ../lab1/listofblogs.cpp:50
qt.core.qobject.connect: QObject::connect:  (receiver name: 'listofblogs')
qt.core.qobject.connect: QObject::connect: No such slot listofblogs::map() in ../lab1/listofblogs.cpp:50
qt.core.qobject.connect: QObject::connect:  (receiver name: 'listofblogs')
qt.core.qobject.connect: QObject::connect: No such signal QSignalMapper::mapped(int) in ../lab1/listofblogs.cpp:54
qt.core.qobject.connect: QObject::connect:  (receiver name: 'listofblogs')

I think it happens because of an error of "connect()" function.

Also, when I changed this part from

connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(doSomething(int)));

to

connect(signalMapper, &QSignalMapper::mappedString,
                this, &listofblogs::doSomething(row));

I got this error and could not compile it.

listofblogs.cpp:51:9: error: no matching member function for call to 'connect'
qobject.h:197:36: note: candidate function not viable: no known conversion from 'void (QAbstractButton::*)(bool)' to 'const char *' for 2nd argument
qobject.h:200:36: note: candidate function not viable: no known conversion from 'void (QAbstractButton::*)(bool)' to 'const QMetaMethod' for 2nd argument
qobject.h:443:41: note: candidate function not viable: no known conversion from 'void (QAbstractButton::*)(bool)' to 'const char *' for 2nd argument
qobject.h:217:43: note: candidate template ignored: couldn't infer template argument 'Func2'
qobject.h:258:13: note: candidate template ignored: couldn't infer template argument 'Func2'
qobject.h:297:13: note: candidate template ignored: couldn't infer template argument 'Func2'
qobject.h:249:13: note: candidate function template not viable: requires 3 arguments, but 4 were provided
qobject.h:289:13: note: candidate function template not viable: requires 3 arguments, but 4 were provided


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source