tags:

views:

30

answers:

2

i got this main;

#include <QtGui>
#include <iostream>
using namespace std;
#include "tray.h"

void main(int argc, char *argv[])
 {
    QApplication app(argc, argv);
    Tray iets;
    app.exec();
 }

when i open in tray something like;

QFileDialog *dialog = new QFileDialog;
QString dir;

QString test = dialog->getOpenFileName(NULL, NULL, NULL, "Battlefield (*.exe)", NULL, NULL);
for(int i=0; i<test.split("/").size()-1; i++)
    dir+= test.split("/").at(i) + "/";
ui->lePath->setText(test);

and i choosed the file its terminating another thread / the program.

how to fi xit?

+1  A: 

I don't know (and can't guess) what your Tray class is.

However, Qt usually terminate the program when the last displayed window (QWidget instance) is closed. Unless specified otherwise.

If Tray is not a window (a child class of QWidget), then app.exec() has no message loop to process and returns immediately, thus terminating the program.

What would you expect/what do you want your program to do at this point exactly ?


Not directly related but still important:

Your main() function really should return an exit status. You can simply change your main() so that it looks like:

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    Tray iets;
    return app.exec(); // app.exec() returns an exit status.
}
ereOn
A: 

i got a tray class, it just make the tray icon & a menu on it. i got a menu option settings which open a gui, after closing it it stops.

Stefan
Please read the [FAQ][http://stackoverflow.com/faq]. StackOverflow is not a forum: Don't use the "Add answer" button to reply to someone who helped you: add a comment to his answer or to your question instead.
ereOn