PDA

View Full Version : 4.4.3 Windows - Missing MainWindow when starting Application on other machine



nando76
28th January 2009, 09:00
Hi,

i have an executable which works fine. When started it shows a MainWindow and a login (q)dialog (which prompts the user to enter username/password).
Everything works fine.

When i now copy the complete directory which contains the executable an all Qt DLLs + mingw DLL to another host which has not Qt installed, OR when i create an installer package (with nsis or installJammer)
and install it on another host the MainWindow does not appear if the executable is started....
Very strange......

I start the executable and only the login dialog comes up......After logging in (the dialog exec finishes) the MainWindow pops up....
How can there a different behaviour between host where it has been compiled and another machine?

Any ideas?

Marco

wysota
28th January 2009, 09:18
Can we see the code of your main()?

nando76
29th January 2009, 07:32
Hi,
sure....
here is my main:



int main(int argc, char **argv)
{
// Prepare log system
CConsoleLog *pConsoleLogger = new CConsoleLog;

std::string Prefix("test");
CFileLog *pFileLogger = new CFileLog(Prefix, false);

CLog::instance()->registerLogDevice(pConsoleLogger);
CLog::instance()->registerLogDevice(pFileLogger);

CLog::instance()->enableDEBUG(true);
CLog::instance()->enableMESSAGE(true);
CLog::instance()->enableWARNING(true);
CLog::instance()->enableERROR(true);
CLog::instance()->enableFATAL(true);

QString Application (QString(Flightbook::APP_STRING) + " ");

FlightbookManager::instance().setApplicationTitle( Application);


LOG_MESSAGE("Starting " << argv[0] <<
" compiled: " << __DATE__ << ", " << __TIME__);

QApplication App(argc, argv);

#ifdef WIN32
QApplication::setStyle(new QWindowsVistaStyle);
// QApplication::setStyle(new QWindowsStyle);
#endif


QCoreApplication::setOrganizationName("TEST");
QCoreApplication::setOrganizationDomain("test123.de");
QCoreApplication::setApplicationName("TEST APP");

QPalette Palette;
Palette.setColor(QPalette::Highlight, QColor(1,1,255,200));
Palette.setColor(QPalette::HighlightedText, QColor(255,255,255));
App.setPalette(Palette);

App.setWindowIcon(QIcon(":/images/applicationicon.png"));
int ret = 0;
{

MainWindow *pMainWin = new MainWindow;
pMainWin->show();

QPixmap Splash(":/images/splash.png");
QSplashScreen *pSplash = new QSplashScreen(Splash);

pSplash->showMessage(Application, Qt::AlignLeft|Qt::AlignBottom,
QColor(255, 255, 255));
pSplash->show();
if(!pMainWin->initialize()) {
LOG_FATAL("Couldn't initialize, aborting...");
shutdown();
return 1;
}

pSplash->finish(pMainWin);

delete pSplash;

pMainWin->login("");

ret = App.exec();

delete pMainWin;

shutdown();
}

return ret;
}

wysota
29th January 2009, 08:26
In this code I can only see one window that has a chance of being visible - pMainWin. Which is the other one?

nando76
29th January 2009, 09:49
the main window:

class MainWindow : public QMainWindow
{
Q_OBJECT
....


and in the main.cpp the login method of mainwinow is called which creates the
login dialog (QDialog) :


bool
MainWindow::login(const QString &DefaultPilot, bool bInitialLogin)
{
Flightbook::centerInDesktop(*this);

if(m_pLoginDialog)
{
delete m_pLoginDialog;
}

m_pLoginDialog = new LoginDialog(DefaultPilot);
.....


So the login dialog always appears. Only the MainWindow isn't shown on virgin machins (with no Qt installed).....
After login winow finishes first time the MainWindow comes up...

nando

wysota
29th January 2009, 10:14
Do you use exec() or show() to show the login dialog?

nando76
29th January 2009, 13:35
Hi,

i use exec

nando

wysota
29th January 2009, 19:47
In that case you are probably suffering from QApplicaton::quitOnLastWindowClosed. Set it to false and see if it makes a difference.