s410i
21st June 2008, 11:34
Hello!
I just started learning qt and I have some questions. I've write a simple program but something is wrong. When the button is clicked() it should write a value on the LCD Screen but there is only a warning: ''Object::connect: No such slot QLCDNumber::display(5)'' ,but I've read that there is a slot like 'display(int num)'
#include <QApplication>
#include <QFont>
#include <QPushButton>
#include <QWidget>
#include <QLCDNumber>
class MyWidget : public QWidget
{
public:
MyWidget(QWidget *parent = 0);
};
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
{
setFixedSize(200,120);
QPushButton *quit = new QPushButton(tr("Click"),this);
QLCDNumber *lcd = new QLCDNumber(2,this);
quit -> setGeometry(62,40,75,30);
quit -> setFont(QFont("Times", 18, QFont::Black, true));
connect(quit,SIGNAL(clicked()),lcd,SLOT(display(5) ));
}
int main(int argc, char *argv[])
{
QApplication app(argc,argv);
MyWidget widget;
widget.show();
return app.exec();
}
Thanks, for the answers.
I just started learning qt and I have some questions. I've write a simple program but something is wrong. When the button is clicked() it should write a value on the LCD Screen but there is only a warning: ''Object::connect: No such slot QLCDNumber::display(5)'' ,but I've read that there is a slot like 'display(int num)'
#include <QApplication>
#include <QFont>
#include <QPushButton>
#include <QWidget>
#include <QLCDNumber>
class MyWidget : public QWidget
{
public:
MyWidget(QWidget *parent = 0);
};
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
{
setFixedSize(200,120);
QPushButton *quit = new QPushButton(tr("Click"),this);
QLCDNumber *lcd = new QLCDNumber(2,this);
quit -> setGeometry(62,40,75,30);
quit -> setFont(QFont("Times", 18, QFont::Black, true));
connect(quit,SIGNAL(clicked()),lcd,SLOT(display(5) ));
}
int main(int argc, char *argv[])
{
QApplication app(argc,argv);
MyWidget widget;
widget.show();
return app.exec();
}
Thanks, for the answers.