PDA

View Full Version : show a pop up or message box in my console application



rinku
10th August 2012, 06:59
i am new in qt . i have written a console application . now i want to show a message box or pop up message in run time . how to do this?

BalaQT
10th August 2012, 09:14
messagebox is in QtGui, u need to link against them.
My suggession is u can simply print the message.

hope it helps
Bala

rinku
18th August 2012, 15:20
can u give me some idea how to link console application with QtGui .. thanks

Zlatomir
18th August 2012, 16:45
See in the .pro file and if you have something like QT -= gui delete it (the gui module should be included by default, if not explicitly removed)

Also you also need a QApplication (http://doc.qt.nokia.com/4.7-snapshot/qapplication.html), because QCoreApplication (http://doc.qt.nokia.com/4.7-snapshot/qcoreapplication.html) is not enough.

rinku
20th August 2012, 06:00
ok you are saying i need QApplication,so only including the "QApplication.h" will be enough?

yeye_olive
20th August 2012, 15:47
No, you need to instantiate QApplication instead of QCoreApplication as your application currently does.

Your application will not be a console application anymore. It will be a GUI application that happens to be interacting primarily through its standard input and output streams.

rinku
21st August 2012, 11:29
ok but my application is console application. i have added one Qtdesigner form.. now i am facing problem to how to call that form from my application.. i dont have any other options.

spirit
21st August 2012, 11:38
It's odd situation of using console based app with ui. Why do you need such behavior?

yeye_olive
21st August 2012, 13:31
Why do you keep calling "console application" an application that displays message boxes and forms designed in QtDesigner? It is a GUI application, and you must instantiate QApplication. This does not prevent you from reading from the standard input and writing to the standard output like console applications do.

All you have to do is instantiate the widgets, show them when you feel like it, and make sure an event loop runs for the user to interact with them. You can use std::cin and std::cout as much as you want.