Qt connects “no such slot” when the slot definitely exists

Qt v4.8.0, compiler VC2010

I have a QMainWindow-based class and I'm trying to send its signals using QUuid

However, every time I run it, I get errors:

Object::connect: No such slot MainWindow::on_comp_connected(QUuid) in ..\..\src\mainwindow.cpp:143
Object::connect:  (receiver name: 'MainWindow')

It makes me a handful since the slot definitely exists (it's in moc _)

class MainWindow : public QMainWindow
{
Q_OBJECT

// SNIP private typedefs

public:
    MainWindow(QWidget *parent = 0, Qt::WFlags flags = 0);
    ~MainWindow();
// SNIP public methods

signals:
   void testSendQuuid(const QUuid &qcid);

public slots:
   void on_comp_connected(const QUuid &qcid);

private:
// SNIP private parts

QOpenAcnController *acnInt;  // This is where the signal comes from

};

At the end of the MainWindow constructor (line 143 specified), I:

connect(acnInt, SIGNAL(callback_comp_connected(QUuid)),
        this, SLOT(on_comp_connected(QUuid)));

Given that the slot is definitely present in the moc_mainwindow.cpp file (I checked its slot # 1), what could stop the connection from stopping?

If I try to connect the testSendQuuid (QUuid) signal to the slot, I do not receive any such signal or any such slot.

I cannot understand for life why Qt denies the existence of a slot, which is definitely there!

+5
source
3

, moc_mainwindow.cpp Build Path. moc_window.cpp. , : QtCreator, . moc_cpp, .

, , moc, , , moc, .

+4

, Q_OBJECT mainwindow.

+3

connect(acnInt, SIGNAL(callback_comp_connected(QUuid)),         this, SLOT(on_comp_connected(const QUuid&))); 

const.

, . QtCreator 2.4.1 Qt 4.7.4 Windows. MainWindow.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    connect(
      this, SIGNAL(testSendQuuid(QUuid)),
      this, SLOT(on_comp_connected(QUuid))
    );
    QUuid x = QUuid::createUuid();
    emit testSendQuuid(x);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_comp_connected(const QUuid &qcid)
{
    ui->label->setText(qcid.toString());
}

uuid .

QUuid , const QUuid & .

So your problem should be with construction.

0
source

All Articles