Results 1 to 9 of 9

Thread: show a pop up or message box in my console application

  1. #1
    Join Date
    Aug 2012
    Posts
    12
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default show a pop up or message box in my console application

    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?

  2. #2
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: show a pop up or message box in my console application

    messagebox is in QtGui, u need to link against them.
    My suggession is u can simply print the message.

    hope it helps
    Bala

  3. #3
    Join Date
    Aug 2012
    Posts
    12
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: show a pop up or message box in my console application

    can u give me some idea how to link console application with QtGui .. thanks

  4. #4
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: show a pop up or message box in my console application

    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, because QCoreApplication is not enough.

  5. #5
    Join Date
    Aug 2012
    Posts
    12
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: show a pop up or message box in my console application

    ok you are saying i need QApplication,so only including the "QApplication.h" will be enough?

  6. #6
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: show a pop up or message box in my console application

    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.

  7. #7
    Join Date
    Aug 2012
    Posts
    12
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: show a pop up or message box in my console application

    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.

  8. #8
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: show a pop up or message box in my console application

    It's odd situation of using console based app with ui. Why do you need such behavior?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  9. #9
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: show a pop up or message box in my console application

    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.

Similar Threads

  1. Why does console show up =.=
    By xleniz in forum Qt Programming
    Replies: 3
    Last Post: 7th June 2012, 14:39
  2. How to show Multiple Message using QSystemTrayIcon?
    By ashukla in forum Qt Programming
    Replies: 5
    Last Post: 22nd May 2009, 10:26
  3. Replies: 4
    Last Post: 12th October 2008, 13:47
  4. StatusBar show message
    By Pang in forum Qt Programming
    Replies: 3
    Last Post: 23rd August 2007, 10:22
  5. console message
    By mickey in forum Qt Programming
    Replies: 6
    Last Post: 29th July 2006, 14:14

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.