KeineAhnung
30th April 2014, 21:13
Hi,
I am trying to connect a custom signal from a custom object to my main window. The custom object is derived from a QGroupBox. I think I set up the signal correctly because auto complete picks it up when I write the connect statement but when I run the program I get the information that there is no such signal in QGroupBox. Why is the program trying to connect a QGroupBox when I used a custom object??? If I use a signal from QGroupBox the program runs fine.
Here is the class definition: .h
#ifndef STATIONCARD_H
#define STATIONCARD_H
#include <QLabel>
#include <QGroupBox>
#include <QLayout>
class StationCard : public QGroupBox{
public:
StationCard();
QLabel *propLabel;
int index;
bool on;
signals:
void toggled(int index, bool on);
private:
};
#endif // STATIONCARD_H
and .cpp
#include "stationcard.h"
StationCard::StationCard(){
QHBoxLayout *layout = new QHBoxLayout;
propLabel = new QLabel();
layout->addWidget(propLabel, 10, Qt::AlignRight);
setLayout(layout);
on = isChecked();
}
The connection is done in my main window when the card is initiated:
StationVector.resize(8);
int k = 0;
for(int i = 0; i < 2; ++i){
for(int j = 0; j < 4; ++j){
StationVector[k] = new StationCard;
StationVector[k]->index = k;
QObject::connect(StationVector[k], SIGNAL(toggled(int, bool)), this, SLOT(on_stationCard_toggled(int, bool)));
ui->cardLayout->addWidget(StationVector[k], i, j);
k++;
}
}
When I run it I get eight times
QObject::connect: No such signal QGroupBox::toggled(int, bool)
QObject::connect: (receiver name: 'MainWindow')
Thanks for helping!
I am trying to connect a custom signal from a custom object to my main window. The custom object is derived from a QGroupBox. I think I set up the signal correctly because auto complete picks it up when I write the connect statement but when I run the program I get the information that there is no such signal in QGroupBox. Why is the program trying to connect a QGroupBox when I used a custom object??? If I use a signal from QGroupBox the program runs fine.
Here is the class definition: .h
#ifndef STATIONCARD_H
#define STATIONCARD_H
#include <QLabel>
#include <QGroupBox>
#include <QLayout>
class StationCard : public QGroupBox{
public:
StationCard();
QLabel *propLabel;
int index;
bool on;
signals:
void toggled(int index, bool on);
private:
};
#endif // STATIONCARD_H
and .cpp
#include "stationcard.h"
StationCard::StationCard(){
QHBoxLayout *layout = new QHBoxLayout;
propLabel = new QLabel();
layout->addWidget(propLabel, 10, Qt::AlignRight);
setLayout(layout);
on = isChecked();
}
The connection is done in my main window when the card is initiated:
StationVector.resize(8);
int k = 0;
for(int i = 0; i < 2; ++i){
for(int j = 0; j < 4; ++j){
StationVector[k] = new StationCard;
StationVector[k]->index = k;
QObject::connect(StationVector[k], SIGNAL(toggled(int, bool)), this, SLOT(on_stationCard_toggled(int, bool)));
ui->cardLayout->addWidget(StationVector[k], i, j);
k++;
}
}
When I run it I get eight times
QObject::connect: No such signal QGroupBox::toggled(int, bool)
QObject::connect: (receiver name: 'MainWindow')
Thanks for helping!