ok here is it i have rewritten everything from the beginning
#ifndef PUSHBUTTON_H
#define PUSHBUTTON_H
#include <QPushButton.h>
{
Q_OBJECT
{
QObject::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.h>
class pushbutton : class QPushButton
{
Q_OBJECT
pushbutton(const QString& text, QWidget* parent = 0) : QPushButton(text, parent)
{
QObject::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
#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
these are the following errors that shows me
C:\Documents and Settings\t\My Documents\project\frontend\pushbutton.h|6|error: expected class-name before 'class'|
C:\Documents and Settings\t\My Documents\project\frontend\pushbutton.h|6|error: expected '{' before 'class'|
C:\Documents and Settings\t\My Documents\project\frontend\pushbutton.h|6|error: redefinition of 'class QPushButton'|
C:\Qt\2010.03\qt\include\QtGui\..\..\src\gui\widgets\qpushbutton.h|58|error: previous definition of 'class QPushButton'|
C:\Documents and Settings\t\My Documents\project\frontend\pushbutton.h|6|error: new types may not be defined in a return type|
C:\Documents and Settings\t\My Documents\project\frontend\pushbutton.h|6|note: (perhaps a semicolon is missing after the definition of '<type error>')|
C:\Documents and Settings\t\My Documents\project\frontend\main.cpp|5|error: two or more data types in declaration of 'main'|
||=== Build finished: 6 errors, 0 warnings ===|
C:\Documents and Settings\t\My Documents\project\frontend\pushbutton.h|6|error: expected class-name before 'class'|
C:\Documents and Settings\t\My Documents\project\frontend\pushbutton.h|6|error: expected '{' before 'class'|
C:\Documents and Settings\t\My Documents\project\frontend\pushbutton.h|6|error: redefinition of 'class QPushButton'|
C:\Qt\2010.03\qt\include\QtGui\..\..\src\gui\widgets\qpushbutton.h|58|error: previous definition of 'class QPushButton'|
C:\Documents and Settings\t\My Documents\project\frontend\pushbutton.h|6|error: new types may not be defined in a return type|
C:\Documents and Settings\t\My Documents\project\frontend\pushbutton.h|6|note: (perhaps a semicolon is missing after the definition of '<type error>')|
C:\Documents and Settings\t\My Documents\project\frontend\main.cpp|5|error: two or more data types in declaration of 'main'|
||=== Build finished: 6 errors, 0 warnings ===|
To copy to clipboard, switch view to plain text mode
please help me Thanks!
Bookmarks