I recently migrated from Qt 3 to Qt4.8 ( I know huge jump.) Was restricted to work on qt3 before. Anyway, I was trying out this particular program, where I am creating two QLineEdit boxes and trying to to get the text of l1 to l2 (l1 and l2 bring the names of the QLineEdit respectively.) For this I was created the signal and slots but when I compile I get this error "Undefined reference to setText()". I was using the signal textChanged() of l1 and slot of l2 - setText(). Think anyone can help me on this?
I think I am just missing something. Got gambled with all the qt3 and 4 concepts. Please pardon my poor code and concepts. Patience would be appriciated. Thanks.
try1.cpp
#include<QtGui>
#include<QDialog>
#include<QLineEdit>
#include<QLabel>
#include<QPushButton>
#include "try1.h"
#include "ui_try1.h"
{
//ui->setupUi(this);
connect(ui
->l1,
SIGNAL(textChanged
(const QString &)),ui
->l2,
SLOT(setText
(const QString &)) );
//connect(ui->Quit,SIGNAL(clicked()),this,SLOT(close()));
}
#include<QtGui>
#include<QDialog>
#include<QLineEdit>
#include<QLabel>
#include<QPushButton>
#include "try1.h"
#include "ui_try1.h"
try1::try1(QWidget *parent):QDialog(parent), ui(new Ui::Dialog)
{
//ui->setupUi(this);
connect(ui->l1,SIGNAL(textChanged(const QString &)),ui->l2,SLOT(setText(const QString &)) );
//connect(ui->Quit,SIGNAL(clicked()),this,SLOT(close()));
}
To copy to clipboard, switch view to plain text mode
try1.h
#ifndef TRY1_H
#define TRY1_H
#include "ui_try1.h"
#include<QDialog>
#include<QLineEdit>
#include<QLabel>
#include<QPushButton>
//class ;
//class QLineEdit;
//class QPushButton;
namespace Ui
{
class Dialog;
}
{
Q_OBJECT
public:
private:
Ui::Dialog *ui;
signals:
void textChanged
(const QString &text
);
// void clicked();
private slots:
//void close();
private:
};
#endif
#ifndef TRY1_H
#define TRY1_H
#include "ui_try1.h"
#include<QDialog>
#include<QLineEdit>
#include<QLabel>
#include<QPushButton>
//class ;
//class QLineEdit;
//class QPushButton;
namespace Ui
{
class Dialog;
}
class try1:public QDialog
{
Q_OBJECT
public:
try1(QWidget *parent=0);
private:
Ui::Dialog *ui;
signals:
void textChanged(const QString &text);
// void clicked();
private slots:
void setText(const QString &text);
//void close();
private:
QLabel *l1;
QLabel *l2;
QLineEdit *t1;
QLineEdit *t2;
QPushButton *Quit;
};
#endif
To copy to clipboard, switch view to plain text mode
main.cpp (init)
#include<QtGui>
#include<QApplication>
#include<QDialog>
#include "try1.h"
int main(int argc,char *argv[])
{
try1 d;
d.show();
return app.exec();
}
#include<QtGui>
#include<QApplication>
#include<QDialog>
#include "try1.h"
int main(int argc,char *argv[])
{
QApplication app(argc,argv);
try1 d;
d.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Also attaching the zip file of the project. And again really sorry for messy code.
Bookmarks