0

私はそのようなコードを持っています:

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

コンポーネント.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

それを使用するフラグメント:

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)));


}

私が得るものは次のとおりです。

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

スロットとシグナルの定義を Component からその派生クラス Przystanki に移動した後に発生しました。ビルドディレクトリ全体を削除し、クリーンを実行し、qmakeを実行してもう一度ビルドしましたが、役に立ちませんでした。誰かが私が間違っていることを説明できますか?

4

1 に答える 1

2

クラス Przystanki に Q_OBJECT マクロがありません。それを追加し、przystanki.h を .pro ファイルの HEADERS に追加して (まだ存在しない場合)、qmake を再実行します。

于 2013-01-13T13:57:58.637 に答える