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. Getting focus on activation window with QtSingleApplication in windows OS and a problem.

Getting focus on activation window with QtSingleApplication in windows OS and a problem.

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 3.9k Views
  • 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.
  • Q Offline
    Q Offline
    quizzical
    wrote on last edited by
    #1

    Hi,

    Try as I might, I have been unable to get the main window(set as the activation window with 'setActivationWindow()) associated with the QtSingleApplication to raise and appear in front of other overlapping windows. I am using Windows OS. It looks it is not easy to do that, from other posts I have seen. Could you suggest a way to do this.

    In addition, I am seeing a problem.

    I have the following code:

    @
    QtSingleApplication theApp( ENF_STRING, argc, argv);

    if (theApp.sendMessage( "act" ) )
    {
    QWidget *theWindow = theApp.activationWindow();

    return 0;
    

    }
    @

    When a second instance of the application runs, I noticed that the activation window is set to null, though it was set previously set with setActivationWindow. But, I can see that the 'sendMessage()' works, because if the window is iconized, and a second instance runs, the window de-minimizes and comes immediately into focus. But, 'theWindow' variable above is null, because the activationWindow is zero.

    What is going on?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Please enclose your code snippets with character '@' for easier reading.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        quizzical
        wrote on last edited by
        #3

        Clarifying my code snippets for you:

        @QtSingleApplication theApp( ENF_STRING, argc, argv);

        @if (theApp.sendMessage( “act” ) )
        @{ QWidget *theWindow = theApp.activationWindow();

        @return 0;
        @}

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          Thanks for adding '@'. Actually, you should start your code section with a ´@' and close it with the character. The plural was not appropriate for you.

          The "example ":http://doc.qt.nokia.com/solutions/4/qtsingleapplication/qtsingleapplication.html is quitting when it sees that there is another instance already running. I would assume that this is the main purpose as the name already suggests. If you really want to run it several times as indicated for the server example, you probably should not activate windows.
          However, I am not an expert in that area, so I am happy to read other comments on this.
          From my point it is somehow strange to use it as you try to do. I would consider the behaviour you encounter as design feature :-)

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giesbert
            wrote on last edited by
            #5

            Hi quizzical,

            Am I right, you try to get the widget pointer of the other running application? That is not possible!
            You can set an activationWindow for the local application / process. and it only works inside this process.

            This sendMessage send a message to the first instance of the QtSingleApplication which resides in a different process. You will not get pointers of that process.

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            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