PDA

View Full Version : QComboBox signal/slot problem, widget



johan07
13th November 2015, 13:11
Hi,
i want add information to QComboBox
so i create it like that

formcharacter=new QWidget(this);
formcharacter->show();

liste = new QComboBox(formcharacter);
connect(myapp,SIGNAL(BoneAdede( QString * )), this, SLOT( BoneAdede( QString *)));



in my mainwindow i defined slot


void MainWindow::BoneAdede( QString name )
{
cout<<"iam BoneAded";
liste->addItem(name);

}

in the class myapp,i difined signal

signals :

void BoneAdede ( QString name );
and

void myapp::create_character(/*QString fname*/)

{
for(unsigned int i = 0; i < skel->getNumBones(); ++i) {
std::string namem=skel->getBone(i)->getName();
emit BoneAdede(QString( namem.c_str()));
}
}


but nothing it happen
the QComboBox is emty, it does not enter to the function BoneAdede( QString name ) in the mainwindows
there is problem in the "connect"??

Edit:
the problem was in " QString *" i must use " QString " :)

Lesiok
13th November 2015, 13:32
In connect statement You are using parameter type QString * (pointer to QString) both for signal and slot. But both definitions have parameter type QString.

johan07
13th November 2015, 15:44
Hi,
is tehre possiblité to made the widget

formcharacter=new QWidget(this);
formcharacter->show();

liste = new QComboBox(formcharacter);
in place better, because now it's in the top of my main windows
can you suggest to me pleaes another emplacement ?