Alright so here is my simple code...
header.cpp
#include<QLabel>
#include<QPushButton>
#include<QVBoxLayout>
#include<QCheckBox>
#include<QLineEdit>
#include"header.h"
{
label
= new QLabel(tr
("Find What"));
label->setBuddy(line);
close->resize(50,30);
find->resize(50,30);
find->setEnabled(false);
find->setDefault(true);
casechk
= new QCheckBox(tr
("Case Sensitive"));
connect(close,SIGNAL(clicked()),this,SLOT(quit()));
connect(line,
SIGNAL(textChanged
(const QString &)),
this,
SLOT(enableFind
(const QString &)));
connect(find,SIGNAL(clicked()),this,SLOT(findClicked()));
lay->addWidget(label);
lay->addWidget(line);
lay->addWidget(casechk);
lay->addWidget(back);
lay->addWidget(find);
lay->addWidget(close);
setLayout(lay);
}
void widg::findClicked()
{
Qt::CaseSensitivity ct = casechk->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive;
if(back->isChecked())
{
emit findprev(text, ct);
}
else
{
emit findnext(text, ct);
}
}
void widg
::enableFind(const QString &text
) {
find->setEnabled(true);
}
#include<QLabel>
#include<QPushButton>
#include<QVBoxLayout>
#include<QCheckBox>
#include<QLineEdit>
#include"header.h"
widg::widg(QWidget *parent)
: QWidget(parent)
{
label = new QLabel(tr("Find What"));
line = new QLineEdit;
label->setBuddy(line);
close = new QPushButton(tr("Close"));
close->resize(50,30);
find = new QPushButton(tr("Find"));
find->resize(50,30);
find->setEnabled(false);
find->setDefault(true);
casechk = new QCheckBox(tr("Case Sensitive"));
back = new QCheckBox(tr("Backward Search"));
connect(close,SIGNAL(clicked()),this,SLOT(quit()));
connect(line,SIGNAL(textChanged(const QString &)),this,SLOT(enableFind(const QString &)));
connect(find,SIGNAL(clicked()),this,SLOT(findClicked()));
QVBoxLayout *lay= new QVBoxLayout;
lay->addWidget(label);
lay->addWidget(line);
lay->addWidget(casechk);
lay->addWidget(back);
lay->addWidget(find);
lay->addWidget(close);
setLayout(lay);
}
void widg::findClicked()
{
QString text = line->text();
Qt::CaseSensitivity ct = casechk->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive;
if(back->isChecked())
{
emit findprev(text, ct);
}
else
{
emit findnext(text, ct);
}
}
void widg::enableFind(const QString &text)
{
find->setEnabled(true);
}
To copy to clipboard, switch view to plain text mode
the header file
#ifndef HEADER_H
#define HEADER_H
#include<QWidget>
{
public:
private slots:
void findClicked();
void enableFind
(const QString &text
);
signals:
void findnext
(const QString &str, Qt
::CaseSensitivity cs
);
void findprev
(const QString &str, Qt
::CaseSensitivity cs
);
private:
};
#endif
#ifndef HEADER_H
#define HEADER_H
#include<QWidget>
class QLabel;
class QPushButton;
class QLineEdit;
class QCheckBox;
class widg:public QWidget
{
public:
widg(QWidget *parent = 0);
private slots:
void findClicked();
void enableFind(const QString &text);
signals:
void findnext(const QString &str, Qt::CaseSensitivity cs);
void findprev(const QString &str, Qt::CaseSensitivity cs);
private:
QLabel *label;
QLineEdit *line;
QPushButton *find;
QPushButton *close;
QCheckBox *casechk;
QCheckBox *back;
};
#endif
To copy to clipboard, switch view to plain text mode
and the main
#include<QApplication>
#include"header.h"
int main(int argc,char *argv[])
{
widg widget;
widget.show();
return app.exec();
}
#include<QApplication>
#include"header.h"
int main(int argc,char *argv[])
{
QApplication app(argc,argv);
widg widget;
widget.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
and i get the following error message
Linking...
header.obj : error LNK2001: unresolved external symbol "protected: void __thiscall widg::findnext(class QString const &,enum Qt::CaseSensitivity)" (?findnext@widg@@IAEXABVQString@@W4CaseSensitivity @Qt@@@Z)
header.obj : error LNK2001: unresolved external symbol "protected: void __thiscall widg::findprev(class QString const &,enum Qt::CaseSensitivity)" (?findprev@widg@@IAEXABVQString@@W4CaseSensitivity @Qt@@@Z)
release/r4.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
r4.exe - 3 error(s), 0 warning(s)
i don't know what to do..!! please help...!!
Bookmarks