PDA

View Full Version : Showing arguments in QMessageBox::information() !



Krish
6th March 2008, 10:17
Hello! Friends,
I have QLineEdit in my designer form and QMessageBox::information() widget to show error's as: -


QMessageBox::information( this, "Invalid Data Entered", "You have entered invalid data\n"
"Valid Range is 1 - 1000\n"
"Please enter valid data.", QMessageBox::Ok, 0 );

Now from this small client-server example (http://doc.trolltech.com/3.3/clientserver-example.html) you might be familiar with this: -


QString str = ts.readLine();
emit logText( tr("Read: '%1'\n").arg(str) );

concept where logText() is having a QString-->"Read: '%1' ". In which '%1' is nothing but the 'str' i.e. readLine() which is passed to it.

So just as in this example where the string from outside is displayed, can i use same concept to show string in QMessageBox taken from LineEdit->text()?
To change the above QMessage::information(), i tired this: -


QMessageBox::information( this, "Invalid Data Entered","You have entered" '%1' "which is an invalid data\n"
"Valid Range is 1 - 1000\n"
"Please enter valid data.", QMessageBox::Ok, 0 );

but i dont know how to or where to insert this
.arg(inpuLineEdit->text()) statement so that it will take the input & display it in QMessageBox.

Can anyone please help me out in this? I will be grateful.

Thanks in advance.:)

jpn
6th March 2008, 10:24
QMessageBox::information(...., QString("foo %1 bar").arg(parameter), ...);

PS. Could you start using the "#"-button (produces syntax highlighted code) instead of colors, please?

Krish
11th March 2008, 11:46
Hello! Jpn,
Thanks Sir for helping me out. I tired few things with that and yes now its working!:)

You are as usual a great help to me.---->Thanks very much Sir:)

Best Regards.