here is the main.cpp
#include <QApplication>
#include "pushbutton.h"
int main(int argc, char* argv[])
{
pushbutton *button = new pushbutton("Dont click me");
button->show();
return app.exec();
}
#include <QApplication>
#include "pushbutton.h"
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
pushbutton *button = new pushbutton("Dont click me");
button->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
here is the pushbutton.h
#ifndef PUSHBUTTON_H_
#define PUSHBUTTON_H_
#include <QPushButton>
{
Q_OBJECT
public:
{
connect(this,SIGNAL(clicked()),this,SLOT(change()));
}
public slots:
void change()
{
if(this->text() == "Don't click me!")
{
setText("Click me!");
return;
}
setText("Don't click me!");
}
};
#endif
#ifndef PUSHBUTTON_H_
#define PUSHBUTTON_H_
#include <QPushButton>
class pushbutton : public QPushButton
{
Q_OBJECT
public:
pushbutton(const QString& text, QWidget* parent = 0) : QPushButton(text, parent)
{
connect(this,SIGNAL(clicked()),this,SLOT(change()));
}
public slots:
void change()
{
if(this->text() == "Don't click me!")
{
setText("Click me!");
return;
}
setText("Don't click me!");
}
};
#endif
To copy to clipboard, switch view to plain text mode
ok i did some research and this is what i did
first i runned the qmake -project with folder source as my project folder like
c:/document......../myproject>qmake -project
c:/document......../myproject>qmake -project
To copy to clipboard, switch view to plain text mode
then i got .pro file which has following data
##Automatically generated by qmake (2.01a) Thu May 5 16:40:27 2011#####
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += pushbutton.h
SOURCES += main.cpp
##Automatically generated by qmake (2.01a) Thu May 5 16:40:27 2011#####
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += pushbutton.h
SOURCES += main.cpp
To copy to clipboard, switch view to plain text mode
but still after doing that i am getting error as
obj\Debug\main.o||In function `pushbutton':|
C:\Documents and Settings\t\My Documents\project\sample\pushbutton.h|11|undefined reference to `vtable for pushbutton'|
C:\Documents and Settings\t\My Documents\project\sample\pushbutton.h|11|undefined reference to `vtable for pushbutton'|
||=== Build finished: 2 errors, 0 warnings ===|
obj\Debug\main.o||In function `pushbutton':|
C:\Documents and Settings\t\My Documents\project\sample\pushbutton.h|11|undefined reference to `vtable for pushbutton'|
C:\Documents and Settings\t\My Documents\project\sample\pushbutton.h|11|undefined reference to `vtable for pushbutton'|
||=== Build finished: 2 errors, 0 warnings ===|
To copy to clipboard, switch view to plain text mode
i am using code blocks IDE.
Now can you guys help me.where am i doing wrong?????
i also did qmake -makefile and got few makefiles even that is not solving the problem.
Bookmarks