A
A
Alrond21982020-08-03 11:26:58
Qt
Alrond2198, 2020-08-03 11:26:58

How to fix Undefined reference to…slot in MainWindow?

I'm trying to get the QTextEdit widgets in the stackedWidget to send textChanged() signals to the MainWindow slot. I still can't understand if it works at all, because it gives a compilation error: undefined reference to MainWindow::on_stackedWidget_itemChanged(). "Clear project" and the assembly clicked, does not help.

mainwindow.h

//
    private slots:
    void on_stackedWidget_itemChanged();
    //


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

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{ui->setupUi(this);
QTextEdit *Text = new QTextEdit;
ui->stackedWidget->insertWidget(0, Text);
connect(Text, SIGNAL(textChanged()), this, SLOT(on_stackedWidget_itemChanged()));
//
}
///
void on_stackedWidget_itemChanged()
{
    qDebug()<<"Nice";
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alrond2198, 2020-08-03
@Alrond2198

Stupid mistake, I forgot to write MainWindow:: when defining the method.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question