2

I use Qt5.2 (git) with MSVC13 on Windows. If I build any application (even the templates) it always opens in a cmd.exe window. I tried different Qt versions and different compilers (even MinGW), but I always have the same problem. If however, I start the application using the green play button in QtDesigner it opens without a cmd window. As suggested here I tried "CONFIG -= console" with no effect. Also I dont use testlib. In my qmake.conf I see the line "QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWS"

Does this depend on the dll files I put in the application directory? QtDesigner does not copy any dlls to the build folder, however it sets some environment variables. To run the application from a separate folder I copy the corresponding dlls from the Qt lib folder into the applications exe folder.

Any ideas for this strange behaviour?

Community
  • 1
  • 1
DayAndNight
  • 197
  • 2
  • 12
  • Do you happen to use qdebug? – friendzis Dec 10 '13 at 15:29
  • No, i don't think so, it also happend with template projects and using the release dll's – DayAndNight Dec 16 '13 at 11:15
  • Try using dependency walker - you might have "global" dll somewhere. I don't have MSVC13 so I can't investigate that. Do you use Express edition or a full featured one? – friendzis Dec 16 '13 at 15:21
  • Im using a full featured version of MSVC13, however Im only using the MSVC compiler but QtCreator as IDE. PS: Please replace QtDesigner with QtCreator in my previous post ;) – DayAndNight Dec 17 '13 at 17:19

3 Answers3

3

In MSVC 2013 go to your project properties/ linker and change from:

/SUBSYSTEM:CONSOLE

To:

/SUBSYSTEM:WINDOWS

It worked for me.

TODO

Kirell
  • 9,228
  • 4
  • 46
  • 61
  • I tried to set the "QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:WINDOWS" flag separately as additional make flag from QtDesigner, however it doesn't make a difference – DayAndNight Dec 16 '13 at 11:21
  • Do you use MSVC or QtCreator? You said MSVC in the question. – Kirell Dec 16 '13 at 11:56
  • I use MSVC13 compiler with QtCreator as IDE. However the problem consists with different compilers now. Might it be a problem that I'm using the SVN version of Qt? This problem didn't occur with a precompiled version of Qt with MSVC12 on my old setup. – DayAndNight Dec 17 '13 at 17:21
2

Ok, this took a while, but i finally found the solution here: Hide console of Windows Application

I had to replace the main entry function:

Replace the following code:

int main(int argc, char *argv[])
{
     QApplication app(argc, argv);
     // your code*
}

by

int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, char*, int nShowCmd)
{
    int argc = 0;
    QApplication app( argc, 0 );
 }

Thanks everybody!

Community
  • 1
  • 1
DayAndNight
  • 197
  • 2
  • 12
0

Is the checkbox run in terminal checked?

enter image description here

Thomas Ayoub
  • 29,063
  • 15
  • 95
  • 142
  • No, run in terminal is not checked. However I'm experiencing exactly the opposite effect. If I start my program from QTDesigner it does not open a console. If however I start it from the windows explorer as a standalone program it starts the console. – DayAndNight Dec 16 '13 at 11:19
  • @DayAndNight did you look at [this](http://stackoverflow.com/questions/760323/why-does-my-qt4-5-app-open-a-console-window-under-windows?lq=1) ? – Thomas Ayoub Dec 16 '13 at 11:36
  • Yep, thanks, I tired the suggestions stated in my original post but unfortunately the problem still consists. – DayAndNight Dec 17 '13 at 17:22