Trouble with slots and signals
-
Ok, i don't know how to explain it but i'm trying connect signals and slots but i'm having trouble such as this.
@Object::connect: No such signal QComboBox::currentIndexChanged(X) in .\qttrail.cpp:33
Object::connect: (receiver name: 'QtTrailClass')@here is the code:
@#include "qttrail.h"
#include <QtGui/QPushButton>
#include <QtGui/QComboBox>
#include <Windows.h>
QtTrail::QtTrail(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
pBox = new PaintBox();
pBox->show();QWidget* entity_tools = new QWidget(pBox);
pBox->addItem(entity_tools, "Entities");
QAction* push = new QAction("Add Light",pBox);
QComboBox* com = new QComboBox(ui.page);
this->nameList.push_back("Eggman");
this->nameList.push_back("Snively");for(int X = 0; X < nameList.size()-1; ++X)
{
com->insertItems(X,nameList);
}
int X = com->currentIndex();if(X == 1)
{
MessageBoxA(NULL,"EE","",MB_OK);
}
QObject::connect(com,SIGNAL(currentIndexChanged(X)),this,SLOT(setCurrentIndex(X)));}@
-
nope still didn't this happens a lot to me for some reason I'm trying to make it so depending on the index pickec in the combo box it does different things. Maybe i don't fully understand slots and signals....hmm
-
yea, so if i want to set the current index of the combo box, i gotta do com->setCurrentIndex(int)? like i said Qt's slots and signals are a bit weird to get used to
-
now you want to set the currentindex for the combobox?!
In your first post you wanted to use a slot for this which is your QtTrail class.Normally you use a combobox to select items in it and based on that selection you can use the information to do something with it elsewhere.
can you explain in your own words what you want to accomplish?
This is good reading to learn more about signal slots :
http://developer.qt.nokia.com/doc/qt-4.7/signalsandslots.html -
[quote author="ProgrammerAtHeart3344" date="1309702177"]nope still didn't this happens a lot to me for some reason I'm trying to make it so depending on the index pickec in the combo box it does different things. Maybe i don't fully understand slots and signals....hmm[/quote]
A signal can't be dependent on the parameter value, it's is translated to a function call. That's whxy it must be int not X.