views:

326

answers:

3

I'm learning c++ and QT and would like to be able to launch windows from a console application. Is this even possible?

A: 

If you are using MSVC you can try setting Subsystem->Console in Project Settings->Linker->System.

But why do you need such behaviour?

Paul
I'm using the new QTCreator IDE to build a console app. It has an option when you start a new application to choose gui or console. So i've chosen console. I just want simple textual interface where results can be displayed in QT-gui windows. Should I just choose another approach?
I do not have access to QtCreator now, but as far as I remember this choice only affect whether QCoreApplication or QApplication is created in your main() function.
Paul
The question is: what do you need console application for?If you want to be able to run application without GUI running, you should use QCoreApplication, but I am not sure you will be able to create QWidgets in this case.
Paul
Maybe it is OK in your case to create console-like window and use QApplication.
Paul
A: 

Yes, it's possible. We can't help you unless you describe what you've tried and what exactly isn't working.

Joe Gauterin
I'm using the new QTCreator IDE to build a console app. It has an option when you start a new application to choose gui or console. So i've chosen console. I just want simple textual interface where results can be displayed in QT-gui windows. Should I just choose another approach?
psuedo code of my console main.cpp, then inside the doStuffIn function planned on do various socket/db/explore other qt things, where the results I could build QT guis and launch results fromvoid main() { while("exit" != in) { cin >> in; if (in != "exit") doStuffWith(in); }}
+1  A: 

This is possible, but I think you might be better served by separating the GUI and console portions into separate programs, and running the GUI parts from the console program. Otherwise, you will probably have to mangle one of the paradigms involved: console apps generally don't use event loops, but your GUI windows will not respond to anything unless you let Qt take over and run with its own event loop.

Caleb Huitt - cjhuitt