Reputation: 19
i m a beginner in c++ and i have a question. how can i combine a variable and a string in the folowing line.
QMessageBox::Question(this,"Report", "the Report is in Path: " + pdfPath + "saved, do you want to open it", QMessageBox::Yes | QMessageBox::No);
pdfPath
is my Variable where the path of my pdf-file is saved.
I tried this, ("the Report is in Path: " + pdfPath + "saved, do you want to open it") but it does not work. Thank you in advance :)
Upvotes: 1
Views: 128
Reputation: 48287
if pdf path is not a QString then you can to convert it into one,
//
std::string pdfPath="C:\here!";
QMessageBox::question(this, "Report", "The Report is in Path: " + QString::fromStdString(pdfPath) + "saved, do you want to open it", QMessageBox::Yes | QMessageBox::No);
//
concatenating QStrings works straigh forward cos the operator + is overloaded
QString pdfPath="C:\here!";
QMessageBox::question(this, "Report", "The Report is in Path: " + pdfPath + "saved, do you want to open it", QMessageBox::Yes | QMessageBox::No);
Upvotes: 1