[solved]messagebox in qt
-
hello.
I want my messagebox to print integer values , i am able to do it with string vals, bt not with integer.
any help in this regard is appreciated.
Thnks.this is what i been doing
@
int i1=10;
QMessageBox msgBox;
msgBox.addButton(QMessageBox::Yes);
msgBox.addButton(QMessageBox::No);
msgBox.setText("MESSAGE BOX");
msgbox.exec();
//I want to print i1 value into messagebox, I read somwhere, + sign is used, but how exactly? is there any other way out?//
@
It throws error when I use it the way we do so in java or in turbo c++ programming. -
Heres what I do.
@
int integerValue = 10;
QMessageBox yesNoMsgBox;
yesNoMsgBox.setWindowTitle("Title of window");
yesNoMsgBox.setText("Text you want to show up");
yesNoMsgBox.setInformativeText(QString("Informative text below the main text with value ").append(QVariant(integerval).toString()));
yesNoMsgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
yesNoMsgBox.setDefaultButton(QMessageBox::Cancel);
switch (yesNoMsgBox.exec()){
case QMessageBox::Yes: {
break;
}
case QMessageBox::No: {
break;
}
case QMessageBox::Cancel: {
break;
}
}
@EDIT: As for the + comment, I didnt see this before. You are able to append strings together with the + sign so the same thing can be done like this as well:
@
yesNoMsgBox.setInformativeText("Informative text below the main text with value " + QVariant(integerval).toString());
@ -
dvez43
Thanks dude. Your tweaking helped me. I guess i am right when i say it uses append method after string text.
I wanted to show up only integer values so i just kept that
@
yesNoMsgBox.setInformativeText(QString("Informative text below the main text with value ").append(QVariant(integerval).toString()));
@
informative text line blank which showed only integer value.
Thanks -
sam
Exactly this is what I wanted.
Thanks