Monday, May 25, 2009

Qt Puzzle (question part)

There are 2 simple Qt programs.

pattern 1
#include <QtGui>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
int source_number = 100;
QString message = "log10("
+ QString::number(source_number)
+ ") = "
+ QString::number(log10(source_number));
QLabel *label = new QLabel(message);
label->show();
return a.exec();
}

pattern 2
#include <QApplication>
#include <QLabel>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
int source_number = 100;
QString message = "log10("
+ QString::number(source_number)
+ ") = "
+ QString::number(log10(source_number));
QLabel *label = new QLabel(message);
label->show();
return a.exec();
}

2 programs are the same mostly, and these seem to run correctly. But, only pattern 1 runs correctly, and pattern 2 doesn't. Why? and How? to be continued...

No comments:

Post a Comment