PDA

View Full Version : (Solved) QLCDNumber simple problem



poporacer
7th January 2011, 05:57
I have a widget with a QLCDNumber that I can't get to display anything. The form was created using Creator and in the constructor for the form, I want to initialize the number. I have read throught the forum and documentation and it should work...not sure why. From what I read, I think that QLCDNumber can take a double or string value. I tried several variations just to get it to work and none of them worked.

here is the code

Timer::Timer(QWidget *parent) :
QWidget(parent),
ui(new Ui::Timer)
{
ui->setupUi(this);
ui->lcdDisplay->display(2345);
//ui->lcdDisplay->display("2345");
//ui->lcdDisplay->display(1234.5);
}
I was looking at this too long...I had a function call later on in the code for initializing everything and it set the number to 0...

ChrisW67
7th January 2011, 06:11
Can you explain what you mean by "can't get to display anything"? You cannot see the QLCDNumber widget at all (it has a frame that is always there), or the number is visible but 0, or something else?

This small program works fine here:


#include <QtGui>
#include <QDebug>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QLCDNumber lcd;
lcd.display(2345);
// These work too
// lcd.display(2345.0);
// lcd.display("2345");
lcd.show();

return app.exec();
}



Edit: OK, you found the problem. Ignore this.