Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Hiding and relaunching the same instance of QApplication
Forum Updated to NodeBB v4.3 + New Features

Hiding and relaunching the same instance of QApplication

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bharath144
    wrote on last edited by
    #1

    Hi there,

    I have a QApplication in which I have a custom QDialog. The dialog offers the users a set of options and then launches a process via QProcess. While the process launched still runs, the app if closed has to still run. To achieve this, I re-implemented the 'closeEvent' of QWidget and accept() or ignore() 'ed the event based on whether a process is launched or not.

    In the closeEvent() function, I am hiding my QDialog. With this, for the user the application is closed (it will however run in the task manager). I expect the user to relaunch the application by running the program again. At this point I need to figure out that another instance is already running and that instance to should come to the foreground.

    Can anyone help me with how I can achieve this?

    Regards,
    Bharath

    Cheers!
    ಮೈ ಗೋ ಭರತ ನಾರಾಯಣ
    Bharath Narayan M G

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qxoz
      wrote on last edited by
      #2

      qtsingleapplication from "qtsolutions":https://qt.gitorious.org/qt-solutions could help you

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bharath144
        wrote on last edited by
        #3

        I read about the qtsingleapplication. I would like to know if there's any other way.

        Cheers!
        ಮೈ ಗೋ ಭರತ ನಾರಾಯಣ
        Bharath Narayan M G

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          qxoz
          wrote on last edited by
          #4

          Can you tell, what kind of solution do you need, and why qtsingleapplication is not suitable?

          1 Reply Last reply
          0
          • B Offline
            B Offline
            bharath144
            wrote on last edited by
            #5

            I don't have a reason why not to use QtSingleApplication, but I used the above technique of hiding the app by overriding the closeEvent of the dialog. And when the 2nd instance of the process is launched, it uses a QSharedMemory to notify the already running instance to bring itself to foreground. The already running instance keeps monitoring changes to QSharedMemory (a QObject timer that expires for every 5 seconds is used). If it detects a change in the shared memory, it brings itself to foreground.

            Cheers!
            ಮೈ ಗೋ ಭರತ ನಾರಾಯಣ
            Bharath Narayan M G

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved