Results 1 to 4 of 4

Thread: how to self-destruct a program

  1. #1
    Join Date
    Aug 2009
    Posts
    122
    Thanks
    74
    Qt products
    Qt4
    Platforms
    Windows

    Default how to self-destruct a program

    Typically when I want to delete a file after the program stops running, I use atexit() and then remove(). Now I need to delete my Qt program itself (the .exe file) after it is done running. It's kind of like a self-destruction I need to achieve. Does Qt offer any solutions for that? I need to send my program to someone for testing. I then I need the program to delete itself because I don't want it to become public. What is the best way to achieve that with Qt? Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to self-destruct a program

    Hi,

    You can create another application "deleteApp" that deletes the file of your application. When your application is going to close you can start the other application using a QProcess.
    In your application you can check if the "deleteApp" file exists to let it start or not.

    But Qt don't will provide this thing for you
    Òscar Llarch i Galán

  3. The following user says thank you to ^NyAw^ for this useful post:

    timmu (21st January 2010)

  4. #3
    Join Date
    Aug 2009
    Posts
    122
    Thanks
    74
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to self-destruct a program

    Thanks a lot!

    I could use a little bit of help with starting another application with QProcess as I've never done this.
    Is there a short example on how this is generally achieved?

  5. #4
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to self-destruct a program

    Hi,

    You can use QProcess:startDeteched to start the second application.
    The second application needs a delay to let the first application stop. There is a second way donig this that is using communication between the two applications.
    Òscar Llarch i Galán

  6. The following user says thank you to ^NyAw^ for this useful post:

    timmu (21st January 2010)

Similar Threads

  1. My first program
    By sayyyed in forum Qt-based Software
    Replies: 4
    Last Post: 28th June 2010, 13:43
  2. a program to start another program.
    By zakis in forum Qt Programming
    Replies: 4
    Last Post: 17th December 2009, 19:25
  3. Replies: 7
    Last Post: 19th January 2008, 15:29
  4. MFC Program in QT
    By sabeesh in forum Qt Programming
    Replies: 34
    Last Post: 26th December 2007, 09:10
  5. How do I make a program out of my program?
    By Randulf in forum Newbie
    Replies: 1
    Last Post: 29th May 2007, 11:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.