PDA

View Full Version : No such slot



ABZB
13th May 2013, 16:45
I am obtaining the following error when I run this program:

"QObject::connect: No such slot MainWindow::read_deck(const QString &fileName) in ../Card_Probability_Calc/mainwindow.cpp:232
The program has unexpectedly finished."


void MainWindow::create_actions()
{
readAction = new QAction(tr("Read new deck"), this);
QObject::connect(readAction, SIGNAL(triggered()), this, SLOT(read_deck(const QString &fileName))); *** point of error

refreshAction = new QAction(tr("Reload current deck"), this);
QObject::connect(refreshAction, SIGNAL(triggered()), this, SLOT(refresh_deck()));

//saveAction = new QAction(tr("Save results to file"), this);
// QObject::connect(saveAction, SIGNAL(triggered()), this, SLOT(save_analysis()));

analyzeAction = new QAction(tr("Perform deck analysis"), this);
QObject::connect(analyzeAction, SIGNAL(triggered()), this, SLOT(analyze_deck()));

QObject::connect(exitAction,SIGNAL(triggered()), qApp, SLOT(quit()));

QObject::connect(btns_a[0], SIGNAL(QPushButton::clicked()), this, SLOT(m_b()));
QObject::connect(btns_a[1], SIGNAL(QPushButton::clicked()), this, SLOT(m_g()));

QObject::connect(btns_a[2], SIGNAL(QPushButton::clicked()), this, SLOT(b_m()));
QObject::connect(btns_a[3], SIGNAL(QPushButton::clicked()), this, SLOT(b_g()));

QObject::connect(btns_a[4], SIGNAL(QPushButton::clicked()), this, SLOT(g_m()));
QObject::connect(btns_a[5], SIGNAL(QPushButton::clicked()), this, SLOT(g_b()));
}


slot:

void MainWindow::read_deck(const QString &fileName)
{
list_sizes[0] = 0;
list_sizes[1] = 0;
list_sizes[2] = 0;
int monster_count = 0;
int spell_count = 0;
int trap_count = 0;
current_file = fileName;
std::string file = fileName.toStdString();
std::string current_card;
QString current_card_q;
std::ifstream infile("file.txt");
int passed_main = 0;
std::string line;
while(std::getline(infile, line))
{
if(line == "#main")
{
passed_main++;
}
else if(line == "#extra")
{
passed_main++;
}
else if(passed_main == 1)
{
current_card = read_name(line);
current_card_q = QString::fromUtf8(current_card.c_str());
QListWidgetItem *new_item = new QListWidgetItem;
new_item->setText((current_card_q));
mn_lst->QListWidget::addItem(new_item);
list_sizes[0]++;
read_type(current_card);
}
}
}



slots def.

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
MainWindow();

std::string read_name(const std::string idnum);
int read_number(const std::string idnum);
int read_type(const std::string idnum);
QListWidgetItem *items_a[10];
// void save_analysis(const std::string &fileName);
public slots:
void analyze_deck();
void read_deck(const QString &fileName);
void refresh_deck();

void m_b();
void m_g();

void b_m();
void b_g();

void g_m();
void g_b();
.
.
.




I have already forced the _moc file to be redone.

Added after 28 minutes:

Additionally, all of the connects for the pushbuttons are also non-functional

wysota
13th May 2013, 16:47
Don't put variable names in connect() statements. Only types are allowed. Also think where should the value for a slot parameter come from if the signal it connects to doesn't carry any values.

ABZB
13th May 2013, 17:15
Ok, I changed the one function that required a parameter. I am still getting an error. non of my connections are connecting.

QObject::connect: No such signal QPushButton::QPushButton::clicked() in ../Card_Probability_Calc/mainwindow.cpp:245
QObject::connect: No such signal QPushButton::QPushButton::clicked() in ../Card_Probability_Calc/mainwindow.cpp:246
QObject::connect: No such signal QPushButton::QPushButton::clicked() in ../Card_Probability_Calc/mainwindow.cpp:248
QObject::connect: No such signal QPushButton::QPushButton::clicked() in ../Card_Probability_Calc/mainwindow.cpp:249
QObject::connect: No such signal QPushButton::QPushButton::clicked() in ../Card_Probability_Calc/mainwindow.cpp:251
QObject::connect: No such signal QPushButton::QPushButton::clicked() in ../Card_Probability_Calc/mainwindow.cpp:252

Lesiok
13th May 2013, 17:45
In lines with connect change QPushButton::clicked() to clicked().

ABZB
13th May 2013, 18:01
Thanks!! :)