Answer the question
In order to leave comments, you need to log in
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();
//
#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
Stupid mistake, I forgot to write MainWindow:: when defining the method.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question