You are not logged in.

Dear visitor, welcome to KDE-Forum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

dfmax

Beginner

  • "dfmax" started this thread

Posts: 13

Location: Slovenia

  • Send private message

1

Friday, October 15th 2004, 5:13pm

Closing KAplication

I'm sorry to post this, but I just can find a way to close the aplication.
Im trying to close the program when openDialog returns NULL.
BTW testApp is an KWizard class!
Here's the code in main.cpp:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
int main(int argc, char **argv)
{ 
      .....
     
        KApplication app;
        testApp *mainWin = 0;       
        KFileDialog* openDialog;

        if (openDialog->getOpenFileName(":cfg","*") != "")
        {
    
        mainWin = new testApp();
        app.setMainWidget( mainWin );
        
        optionForm *opt; 
        opt = new optionForm(mainWin);
       
        
        mainWin->show();
        mainWin->addPage(opt,"prvi");
        mainWin->showPage(opt);
      }
      else 
        [that's the part that I don't know ] 

     return app.exec();
}


thank you for your help!

jacek

Trainee

Posts: 105

Location: Warsaw, Poland

Occupation: Student

  • Send private message

2

Friday, October 15th 2004, 6:51pm

RE: Closing KAplication

Quoted

Im trying to close the program when openDialog returns NULL.
if (openDialog->getOpenFileName(":cfg","*") != "")

So NULL or empty string?

Why not call exit(0) or just return from main?

Latem

Beginner

Posts: 31

Location: New Brunswick, Canada

Occupation: Student/Programmer

  • Send private message

3

Saturday, October 16th 2004, 2:58am

Shouldn't this work?

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
int main(int argc, char **argv)
{ 
      .....
     
        KApplication app;
        testApp *mainWin = 0;       
        KFileDialog* openDialog;

        if (openDialog->getOpenFileName(":cfg","*") != QString::null)
        {
    
        mainWin = new testApp();
        app.setMainWidget( mainWin );
        
        optionForm *opt; 
        opt = new optionForm(mainWin);
       
        
        mainWin->show();
        mainWin->addPage(opt,"prvi");
        mainWin->showPage(opt);
        return app.exec();
      }
      else 
        return 0;
}


I think that should be ok.
I put QString::null in the if statement cuz I think you want to exit when user presses cancel, in which case I am pretty sure u are returned QString::null.

Latem
The march of progress:
C:
printf("%10.2f", x);
C++:
cout << setw(10) << setprecision(2) << showpoint << x;
Java:
java.text.NumberFormat formatter = java.text.NumberFormat.getNumberInstance();
formatter.setMinimumFractionDigits(2);
formatter.setMaximumFractionDigits(2);
String s = formatter.format(x);
for (int i = s.length(); i < 10; i++) System.out.print(' ');
System.out.print(s);

dfmax

Beginner

  • "dfmax" started this thread

Posts: 13

Location: Slovenia

  • Send private message

4

Monday, October 18th 2004, 11:31pm

It works with

Source code

1
return 0;


thank you! :)