Qmessagebox disappears immediatly
-
why does this code create a Qmessagebox that disappears immediatly?
@ QMessageBox alert;
alert.move(500,500);
alert.adjustSize();
alert.setWindowTitle("File input: vuoto");
alert.setText("Il file di input non contiene caratteri.nRiavviare il programma e scegliere un altro file!");
alert.setVisible(true);
pathInput->close();@pathInput is a QFile.
-
when i use your code the messagebox remains visible unless I close it by clicking the OK button on it.
So there must be something else going on. Can you show some more of your code?
-
That is because your messagebox variable goes out of scope immediately. Instead of setVisible, call exec() on it.
-
@
else
{
QMessageBox alert;
alert.move(500,500);
alert.adjustSize();
alert.setWindowTitle("File input: vuoto");
alert.setText("Il file di input non contiene caratteri.\nRiavviare il programma e scegliere un altro file!");
alert.setVisible(true);
pathInput->close();
}
@ -
your code shows Andre is right.
He can predict the future ;)
-
how can i fix the bug?
-
did you try using
alert.exec();
instead of
alert.setVisible(true);
as Andre suggested? -
thank you very much! this starts:
@
else
{
QMessageBox alert;
alert.move(500,500);
alert.adjustSize();
alert.setWindowTitle("File input: vuoto");
alert.setText("Il file di input non contiene caratteri.\nRiavviare il programma e scegliere un altro file!");
alert.exec();
pathInput->close();
}
@ -
Good. That is nice.
Might I suggest that instead of hard-coding your strings, you surround them with tr() calls? That way, you will be able to translate your application if needed later on. -
Why not just use QMessageBox::information( ... , QMessageBox::warning ( ... , etc ?
-
thank you for suggestion. i think it is too complex for me...
for andre: i needn't to relase this freeware... -
[quote author="spode" date="1306768207"]thank you for suggestion. i think it is too complex for me...
for andre: i needn't to relase this freeware...[/quote]???? arre you sure ?
@
QMessageBox::information(this,
"File input: vuoto",
"Il file di input non contiene caratteri.\nRiavviare il programma e scegliere un ro file!");
@ -
you are right! that's not difficult! ;)