PDA

View Full Version : Is it possible to use a #define within the text area of a QMessageBox::about()?



rwhartzell
21st September 2015, 21:03
Given that VERSION is defined like so, is there some way to expand that #define within the text area of a QMessageBox::about() along with other text?



#define VERSION_MAJOR 0
#define VERSION_MINOR 1
#define VERSION_MICRO 0
#define VERSION_SPECIAL ".alpha-1"

#define STRINGIFY0(s) # s
#define STRINGIFY(s) STRINGIFY0(s)
#define VERSION STRINGIFY(VERSION_MAJOR) "." STRINGIFY(VERSION_MINOR) "." STRINGIFY(VERSION_MICRO) "" VERSION_SPECIAL


QMessageBox::about(this, tr("About Menu"),
tr("<center><small>VERSION</small></center>"
"<p>Copyright (c) 2015, Bla Bla Bla...</p>"));

jefftee
22nd September 2015, 04:27
QMessageBox::about(this, tr("About Menu"),
tr("<center><small>VERSION</small></center>"
"<p>Copyright (c) 2015, Bla Bla Bla...</p>"));


Are you looking for something like:


QMessageBox::about(this, tr("About Menu"),
tr("<center><small>%1</small></center>"
"<p>Copyright (c) 2015, Bla Bla Bla...</p>").arg(VERSION));

rwhartzell
22nd September 2015, 17:08
Yes thats exactly what I needed, Thanks!