hello i am trying to get this program work but it returns me error
QString.h no such file or directory error!
here is the code
#ifndef PUSHBUTTON_H
#define PUSHBUTTON_H
#include <QPushButton>
#include <QString> //here is where its showing error
{
Q_OBJECT
public:
public slots:
void updatenewvalues()
{
if(this->text() == "Don't click me!")
{
setText("Click me!");
return;
}
setText("Don't click me!");
}
};
#endif // PUSHBUTTON_H
#ifndef PUSHBUTTON_H
#define PUSHBUTTON_H
#include <QPushButton>
#include <QString> //here is where its showing error
class PushButton: public QPushButton
{
Q_OBJECT
public:
PushButton(QWidget* parent = 0): QPushButton(parent){}
PushButton(const QString& text, QWidget* parent = 0) : QPushButton(text, parent){}
public slots:
void updatenewvalues()
{
if(this->text() == "Don't click me!")
{
setText("Click me!");
return;
}
setText("Don't click me!");
}
};
#endif // PUSHBUTTON_H
To copy to clipboard, switch view to plain text mode
int main(int argc, char* argv[])
{
PushButton clickme("Click me!");
clickme.resize(200, 30);
QObject::connect(&clickme,
SIGNAL(clicked
()),
&clickme,
SLOT(updatenewvalues
()));
clickme.show();
return app.exec();
}
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
PushButton clickme("Click me!");
clickme.resize(200, 30);
clickme.setFont(QFont("Times", 18, QFont::Bold));
QObject::connect(&clickme, SIGNAL(clicked()), &clickme, SLOT(updatenewvalues()));
clickme.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Thanks!
Bookmarks