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. How to get focus on First instance of an application using QSharedMemory
Forum Updated to NodeBB v4.3 + New Features

How to get focus on First instance of an application using QSharedMemory

Scheduled Pinned Locked Moved General and Desktop
10 Posts 3 Posters 2.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.
  • IamSumitI Offline
    IamSumitI Offline
    IamSumit
    wrote on last edited by
    #1

    how can we make a single instance application using QSharedmemory. when we try to run for another instance, first instance should get focus and it's window become top window.I want to do it Without using socket or timer.
    Any Help will be appreciated.

    Be Cute

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you try QtSingleApplication ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ankursaxena
        wrote on last edited by
        #3

        Hi Gaist, this is from I am Sumit. Yes, I have tried QtSingleApplication. but still i didn't get focus on first instance . And i m looking for a method rather than using socket or timer.

        Any body have such kind of method. Please suggest me .

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Are you sure you used QtSingleApplication correctly ? That's what "setActivationWindow":http://doc.qt.digia.com/solutions/4/qtsingleapplication/qtsingleapplication.html#setActivationWindow should do

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • A Offline
            A Offline
            ankursaxena
            wrote on last edited by
            #5

            Hi! Gaist. Yes. I have done it using QtSingleApplication and it is working fine. but i want to do it in some other way. Since QtSingleApplication is using socket. and i don't want to use socket or timer. Is it possible to do it in some other way.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              What is the problem with sockets ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • A Offline
                A Offline
                ankursaxena
                wrote on last edited by
                #7

                Actually, I forced to do it using QSharedmemory and *without using socket *. Reason may be possible that socket or timer increase the CPU usage little bit. and we are not supposed to provide CPU to this task since CPU is already very busy in some other important tasks.

                Is it possible using QSharedMemory. is there any such SIGNAL available in QSharedMemory which can emit as soon as second instance present.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  There's no such signal for that, you'll have to implement all the logic yourself. Probably something like polling the memory thus waste CPU cycles for that.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    ankursaxena
                    wrote on last edited by
                    #9

                    Now i m storing the winId into QSharedMemory. and i m hoping to getfocus on that window which has this winId in the execution of second instance. but the problem is that SharedMemory::data is not showing correct value. so how can i get correct value stored in sharedMemory at the time of execution of first instance.

                    It is showing ÝÝÝÝÝÝÝ . I don't know what is that. Please help.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      ankursaxena
                      wrote on last edited by
                      #10

                      AnyOne ???

                      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