PDA

View Full Version : Simple problem



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.

awhite1159
21st June 2008, 12:58
I am a beginner myself but in the reading I have been doing, it was made clear that you cannot declare the parameter names or pass values in the SLOT() of a connect(). You need to change your SLOT(display(5)) to SLOT(display(int)). This slot displays the property which reflects the current value stored by QLCDNumber

Fatla
21st June 2008, 13:36
I 'd the same problem but it has been solved .
You can find "How to make your Slots " :

http://www.qtcentre.org/forum/f-qt-programming-2/t-problem-when-creating-my-own-slot-13980.html

wysota
22nd June 2008, 11:12
http://www.qtcentre.org/forum/faq.php?faq=qt_signalslot#faq_qt_signalslot_with_v alues