console always popup in release mode
HI all,
I had an application which can be launch in GUI mode and in Console Mode :
Code:
#include <QtGui/QApplication>
#include "flashloader.h"
#include "QMap"
#include <iostream>
#include "QMessageBox"
int main(int argc, char *argv[])
{
msgBox.
setText("number of argument : " + QString::number(argc
));
msgBox.exec();
int iCount;
iCount = argc;
QMap<QString, QString> map_args;
FlashLoader w;
if (argc == 1)
{
w.show();
return a.exec();
}
else
{
int i;
for (i=1; i < argc ; i++)
{
std::cout << "MainAppCore argv[" << i << "] : " << List_args.at(i).toStdString() << "\n";
}
return 0;
}
}
In my pro files, I have
(necessary to have console working)
In debug mode all is working well. If I launch the application with no argument I have only the GUI present. If I launch the application with argument I have only the console present. The problem is when I launch the application in release mode ,the console always appears. How can I fix that?
Thanks
Re: console always popup in release mode
Hi,
I think that argc will be 1 if there are no arguments because the application name is inserted as the first argument, so you have to check if argc is bigger than 1.
Re: console always popup in release mode
Hi,
I believe the problems was there. This is why I display a MessageBox. But even in Debug or in Release argc==1 (and I display it in message box).
This code is running well if I launch from QTCreator in debug and Release mode.
But I launch it directly from the exe I have always the console present
Any other Idea?
Re: console always popup in release mode
Because QTCreator put some args to application ? Line 25 detects if You have some args (argc > 1) or not. If You want to run application with exactly one argument line 25 should be :BTW it is better use of QCoreApplication::arguments.
Re: console always popup in release mode
Ok please don't focus on number of arg !!!
If I use this code :
Code:
int main(int argc, char *argv[])
{
FlashLoader w;
w.show();
return a.exec();
}
and in my pro file
If I run in Debug or Release mode through QTcreator I have no console open
If I run directly the exe, I have always console present
Re: console always popup in release mode
Hi,
You can use "--console" as argument to your application. In "main.cpp" you have to search if there is "--console" in some of the arguments. If you find it you can open your application as console and if you don't find it open as GUI.