PDA

View Full Version : QMetaObject::connectSlotsByName: No matching signal



k3ro
21st February 2016, 15:44
Hi,

I'm not using qt designer for this project, I'm doing it all by code. I'm having problems with my signals & slots. I have simple ones working for my mainwindow (exit, etc) but in a dialog window I'm trying to attach 3 slider signals, 1 lineedit and 1 button to 5 functions. All of them are receiving the following error:


QMetaObject::connectSlotsByName: No matching signal for on_sizeslider_valuechanged(int)
QMetaObject::connectSlotsByName: No matching signal for on_skillslider_valuechanged(int)
QMetaObject::connectSlotsByName: No matching signal for on_texslider_valuechanged(int)
QMetaObject::connectSlotsByName: No matching signal for on_enterplayername_textedited(QString)
QMetaObject::connectSlotsByName: No matching signal for on_acceptbutton_clicked()


Here's the relevant code from my .h:



public slots:
void on_sizeslider_valuechanged(int value);
void on_skillslider_valuechanged(int value);
void on_texslider_valuechanged(int value);

void on_enterplayername_textedited(const QString &arg1);
void on_acceptbutton_clicked();


And the .cpp:


//slots (these are at the end of the constructor)
QObject::connect(acceptbutton, SIGNAL(clicked()),this, SLOT(on_acceptbutton_clicked()));
QObject::connect(sizeslider, SIGNAL(valueChanged(int)), this, SLOT(on_sizeslider_valuechanged(int value)));
QObject::connect(namebox, SIGNAL(textEdited(QString)), this, SLOT(on_enterplayername_textedited(const QString)));
QObject::connect(texslider, SIGNAL(valueChanged(int)), this, SLOT(on_texslider_valuechanged(int)));
QObject::connect(skillslider, SIGNAL(valueChanged(int)), this, SLOT(on_skillslider_valuechanged(int)));

}
void Dialog::on_sizeslider_valuechanged(int value){

if (value == 1) {
sizeoptions->setText("Small");
}
if (value == 2) {
sizeoptions->setText("Medium");
}
if (value == 3) {
sizeoptions->setText("Large");
}
if (value == 4) {
sizeoptions->setText("XLarge");
}

//sizechoice = value;
}

void Dialog::on_skillslider_valuechanged(int value){

if (value == 1) {
skilloptions->setText("Shrink & Boost");
}
if (value == 2) {
skilloptions->setText("Gravity Gun");
}
if (value == 3) {
skilloptions->setText("Tron");
}

//skillchoice = value;
}

void Dialog::on_texslider_valuechanged(int value){

if(value == 1){
textcubeimg->setPixmap(QPixmap("checkertexture150x125.png"));
}

if(value == 2){
textcubeimg->setPixmap(QPixmap("checkertexturepink150x125.png"));
}

if(value == 3){
textcubeimg->setPixmap(QPixmap("checkertextureblue150x125.png"));
}

//texchoice = value;
}

void Dialog::on_enterplayername_textedited(const QString &arg1){

playername = arg1;
}

void Dialog::on_acceptbutton_clicked(){
qDebug() << playername;
this->close();
}


Upon running the code, when the dialog window is triggered I receive the following error (for only one of my slots this time):

QObject::connect: No such slot Dialog:: on_sizeslider_valuechanged(int value) in ..\GUINew\dialog.cpp:115
QObject::connect: (receiver name: 'Dialog')


I don't know why, since the function is clearly there and the name is exactly the same. Additionally, the function for the acceptbutton seems to actually be working (the window exits), as does the enterplayername function (using qdebug I can see it is outputting the correct user input). The sliders however either do nothing (sizeslider) or cause the program to crash (skillslider, texslider).

I've tried clean/build/qmake and it hasn't worked. If anyone could shed some light on the situation it'd be appreciated. Thanks!

anda_skoa
21st February 2016, 16:01
That has already been answered hours ago: http://www.qtcentre.org/threads/65293-No-Such-Slot?p=288045#post288045

Don't you think it would be better to check answers to your older questions before posting basically the same question again?

Cheers,
_