PDA

View Full Version : simple QDialog



eric
14th December 2007, 20:32
Hello!

I'd like to make a simple popup dialog that opens after my program is done running. I want it to say "Completed" and display an OK button which would simply close the dialog.
So far I have this:



QDialog okDialog(this, Qt::Dialog);
QLabel doneLabel("Complete");
QPushButton okButton;
okDialog.resize(50,50);

okDialog.exec();
okDialog.raise();
okDialog.activateWindow();


I'd like to know how to add the okButton and the QLabel (wth thext) to the surface of my dialog. Thanks.

jacek
14th December 2007, 21:01
Why can't you use QMessageBox instead?

http://doc.trolltech.com/4.3/tutorial-t5.html

eric
14th December 2007, 21:54
Thanks Jacek for the idea and congrats on becoming a Guru!

I was wondering if you could display integers using message box?
This below code works well:



char message[] = "Text";
QMessageBox::information(this, "Title", message, QMessageBox::Ok);


but when I replace "message" with an integer (int message = 1;) it won't work.
How do you display integers?
For example if I want to say in the message boxt:

"You had 5 files in this folder" and the number 5 was calculated by a formula, not typed in by a programmer.

jacek
14th December 2007, 22:15
Thanks Jacek for the idea and congrats on becoming a Guru!
Thank you. :)


How do you display integers?
First you have to change them into a QStrings. For example using QString::number().

Or even better use QObject::tr() (read the part about the n parameter).