我有一个父类,它的方法可以更改某些信号上的标签图片。例如,当 QComboBox 中发生某些事情时...(valueChanged,已激活)
class parentClass : public QMainWindow
{
Q_OBJECT
...
public slots:
//this is the slot i want to connect to some signal of
//e.g a combo box to change the picture by passed in string
void changePicture(QString fileName);
然后我有了这个孩子:
class childClass : public QObject
{
Q_OBJECT
public:
childClass(parentClass *parent, QTabWidget *tab, QStringList *guards=0);
private:
bool readCombo(QXmlStreamReader *xmlreader);
现在readCombo
我想读取一个字符串并将其传递给更改图片:
QString imageFileName = xmlreader->attributes().value("image").toString();
QSignalMapper * signalMapper = new QSignalMapper(parent);
//this is just one of many trials to get this working, i hope you get the picture
connect(combo , SIGNAL(activated(int)), parent, SLOT(changePicture(QString *)));
signalMapper->setMapping(combo, imageFileName);
但这给了我No such Signal
,No such Slot
或者大写Incompatiple sender/receiver arguments
我将不胜感激,因为语法确实不直观(imo),而且我找不到任何适合我的案例的好的参考(在询问之前做了很多试验和错误)