#ifndef LOTTO_H
#define LOTTO_H
#include <QWidget>
#include <QLabel>
#include <QTextEdit>
#include <QPushButton>
#include <QGridLayout>
class lotto : public QWidget
{
Q_OBJECT
private:
//widget data members
QLabel* numbersLabel;
QTextEdit* numEdit;
QPushButton* lotusButton;
public slots:
int generateLotteryNumbers ();
void displayNumbers();
public:
lotto();
};
#endif // LOTTO_H
#include "lotto.h"
#include <stdlib.h>
#include <time.h>
#include <QWidget>
#include <QGridLayout>
lotto::lotto(){
setWindowTitle("Lotto Numbers");
QGridLayout* layout = new QGridLayout(this);
lotusButton = new QPushButton ("Lotto Numbers");
numbersLabel = new QLabel ("Your lucky numbers are:");
numEdit = new QTextEdit();
layout->addWidget(lotusButton, 0,0);
layout->addWidget(numbersLabel, 1,0);
layout->addWidget(numEdit, 1,1);
setLayout(layout);
//connect signals and slots
connect(lotusButton,SIGNAL(clicked()),this, SLOT(generateLotteryNumbers()));
}
int lotto::generateLotteryNumbers (){
return (rand() % 49)+ 1;
}
void lotto::displayNumbers(){
numEdit->setText(generateLotteryNumbers());
}
I can't get the random numbers to be displayed in the text box. why?