Difference between pattern 1 and pattern 2 is #include declaration. Entire QtGui module is included in pattern 1, and necessary Qt classes are included in pattern 2 one by one.
What happens by this difference? A compile error like below occurs.
log10 method is not found. log10 method is declared on <cmath>, and probably, some class in QtGui module includes it. But, it isn't QApplication class or QLabel class. So pattern 2 need to include <cmath> explicitly like below.
int main(int argc, char *argv)
QApplication a(argc, argv);
int source_number = 100;
QString message = "log10("
+ ") = "
QLabel *label = new QLabel(message);
Then, compile and run successfully. This dialog appears.