QConnect find no such slot on QCombobox by Qt Creater

Posted by user2534154 on Stack Overflow See other posts from Stack Overflow or by user2534154
Published on 2014-08-24T10:17:24Z Indexed on 2014/08/24 10:20 UTC
Read the original article Hit count: 147

Filed under:
|
  • I create a window inherit from QWidget
  • I set grid layout to that Window
  • I make a function called handleHeroChange(int index) in public slot inside that window
  • I add a Qcombobox to call that function handleHeroChange(int index). Qtcreator keep telling: QObject::connect: No such slot QWidget::handleHeroChange(int) in ../Testing/Window.cpp:92 Why did i do wrong?

THE CODE:

Window::Window(QWidget *parent)
    : QWidget(parent)
{

   QGridLayout *grid = new QGridLayout(this);
   QComboBox *comboHeroClass = new QComboBox();
    comboHeroClass->addItem("Witcher");
    comboHeroClass->addItem("Maurander");
    comboHeroClass->setCurrentIndex(1);
    grid->addWidget(comboHeroClass, 2,3,1,1);
    QComboBox::connect(comboHeroClass, SIGNAL(currentIndexChanged(int)),this, SLOT(handleHeroChange(int)));
}

void Window::handleHeroChange(int index){
    QPixmap myImage;
    if(index == 0){

    }else if(index == 1){

    }
}

© Stack Overflow or respective owner

Related posts about c++

Related posts about qt