i have finally done that/ but it still does not work((( maybe there are new mistakes??
//mybtn.h
#ifndef MYBTN_H
#define MYBTN_H
#include <QtGui>
#include <QString>
{
Q_OBJECT
public:
public slots:
};
#endif
//mybtn.h
#ifndef MYBTN_H
#define MYBTN_H
#include <QtGui>
#include <QString>
class mybtn : public QPushButton
{
Q_OBJECT
public:
mybtn(QString txt);
public slots:
void setTxt(QString txt = "hi!");
};
#endif
To copy to clipboard, switch view to plain text mode
//mybtn.cpp
#include <mybtn.h>
{
setText(txt);
}
{
setText(txt);
emit clicked();
}
//mybtn.cpp
#include <mybtn.h>
mybtn::mybtn(QString txt)
{
setText(txt);
}
void mybtn::setTxt(QString txt)
{
setText(txt);
emit clicked();
}
To copy to clipboard, switch view to plain text mode
//w3.cpp
#include <mybtn.h>
#include <QApplication>
#include <QObject>
int main(int argc, char **argv)
{
mybtn *btn = new mybtn("Press me))");
btn->show();
return app.exec();
}
//w3.cpp
#include <mybtn.h>
#include <QApplication>
#include <QObject>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
mybtn *btn = new mybtn("Press me))");
QObject::connect(btn, SIGNAL(clicked()), btn, SLOT(setTxt(QString)));
btn->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
the application compiles successfully but the button does not change its text((
Bookmarks