Results 1 to 3 of 3

Thread: Restart aplication with some proprieties from the previous

  1. #1
    Join Date
    Mar 2013
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Restart aplication with some proprieties from the previous

    I have a Qt application in which I want to put a restart button, but when it restarts I want it to automatically reconnect with my bluetooth device. here's my code:

    Qt Code:
    1. void gui::restartapp()
    2. {
    3. int index_combo;
    4.  
    5. index_combo= ui->devices_infile->currentIndex();
    6.  
    7. QProcess::startDetached(QApplication::applicationFilePath());
    8. exit(12);
    9.  
    10. char *dest;
    11. dest = addr_infile[index_combo];
    12.  
    13. sock = linkup_directmain(dest, sock);
    14.  
    15. if (sock != 0 && sock >0)
    16. {
    17. ui->console_1->setText("Connected to:");
    18. ui->console_2->setText(name_infile[index_combo]);
    19. }
    20.  
    21. else if (sock == -1)
    22. {
    23. ui->console_1->setText("Error connecting");
    24. ui->console_2->setText("Check device status");
    25. }
    26. }
    To copy to clipboard, switch view to plain text mode 

    but it only restarts. any idea?

    Thank you in advance.

  2. #2
    Join Date
    Dec 2011
    Posts
    27
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Restart aplication with some proprieties from the previous

    Having no idea what the rest of your code does, it's kind of impossible to tell you what is wrong.

    However, consider a pattern:

    (operating)
    - Write current state to a file

    (starting)
    - If a state file exists, read it.
    - If the state inside of that file indicates to do something, do it.

  3. #3
    Join Date
    Mar 2013
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Restart aplication with some proprieties from the previous

    I got it to work with `QSettings`. I'll publish it later in case someone else needs it. It can work with a file as well as you say.

Similar Threads

  1. How execute a script in a Qt aplication?
    By Gerard in forum Qt for Embedded and Mobile
    Replies: 8
    Last Post: 7th September 2011, 14:11
  2. synchronization time in client/server aplication
    By sali555 in forum Qt Programming
    Replies: 1
    Last Post: 3rd May 2011, 14:07
  3. Simple CAD aplication - how to
    By tommnaj in forum Newbie
    Replies: 3
    Last Post: 5th April 2011, 22:47
  4. Aplication just works where it was compile
    By metRo_ in forum Qt Programming
    Replies: 7
    Last Post: 12th April 2010, 23:02
  5. Creating a STANDALONE aplication
    By Alienxs in forum KDE Forum
    Replies: 4
    Last Post: 17th August 2006, 16:02

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
  •  
Qt is a trademark of The Qt Company.