0

I've got such piece of code:

przystanki.h

#ifndef PRZYSTANKI_H
#define PRZYSTANKI_H
#include "component.h"
class Przystanki : public Component
{
public:
    Przystanki(QWidget *parent = 0);

signals:
    void deletePosition(QString);
public slots:
    void deleteListItem();
    void addListItem(QString label);
    void createListItem(QString label, DodajPrzystanek* elem);

};

#endif // PRZYSTANKI_H

component.h

#ifndef COMPONENT_H
#define COMPONENT_H
#include <QListWidget>
#include <QGroupBox>
#include "dodajprzystanek.h"
class Component : public QGroupBox
{
    Q_OBJECT
public:
    explicit Component(QString name, QWidget *parent = 0);
    QListWidget* list;

};

#endif // COMPONENT_H

fragment which uses it:

MyWindow::MyWindow(QWidget *parent) :
QMainWindow(parent)
{
webView = new MyWebView(this);
mainlayout = new QGridLayout();
mainlayout->addWidget(webView, 0,0);
Przystanki *stop = new Przystanki(this);
mainlayout->addWidget(stop, 0, 1);
QHBoxLayout* bottom = new QHBoxLayout();
//bottom->addWidget(new QLabel("Linie"));
bottom->addWidget(new Component("Autobusy"));
bottom->addWidget(new Component("Linie"));
QHBoxLayout* hrightCorner = new QHBoxLayout();
QVBoxLayout* rightCorner = new QVBoxLayout();
rightCorner->addStretch(1);
rightCorner->addWidget(new QPushButton("Start", this));
//QLabel* label = new QLabel("Labelka");

//rightCorner->addWidget(label);
rightCorner->addStretch(1);
hrightCorner->addLayout(rightCorner);
mainlayout->addLayout(bottom, 1, 0);
mainlayout->addLayout(hrightCorner, 1, 1);
hrightCorner->setAlignment(Qt::AlignCenter);
this->setCentralWidget(new QWidget);
this->centralWidget()->setLayout(mainlayout);
connect(webView, SIGNAL(getMapPosition(QString)), stop, SLOT(addListItem(QString)));
connect(stop, SIGNAL(deletePosition(QString)), webView, SLOT(deleteMarker(QString)));


}

What I get is:

loaded the Generic plugin 
Object::connect: No such slot Component::addListItem(QString)
Object::connect: No such signal Component::deletePosition(QString)

It happend after I moved definitions of slots and signals from Component to it's derived class Przystanki. I've removed whole build directory, run clean, run qmake and build one more time and it didn't help. Can anyone explain to me what I'm doing wrong?

Wojciech Reszelewski
  • 2,656
  • 2
  • 18
  • 27
  • 2
    I don't see here in this piece of code any relevant `connect` calls. Also, there should be filename and line, where does that connect occures. – hate-engine Jan 13 '13 at 13:54
  • I've editted the question. I removed a few first lines with no slot becouse in this case the slot was really missing. – Wojciech Reszelewski Jan 13 '13 at 14:03

1 Answers1

2

Your class Przystanki is missing the Q_OBJECT macro. Add it, add przystanki.h to HEADERS in the .pro file (if not there yet) and rerun qmake.

Frank Osterfeld
  • 24,815
  • 5
  • 58
  • 70