Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

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

    General and Desktop
    3
    5
    3644
    Loading More Posts
    • 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
      quizzical last edited by

      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 Reply Quote 0
      • K
        koahnig last edited by

        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 Reply Quote 0
        • Q
          quizzical last edited by

          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 Reply Quote 0
          • K
            koahnig last edited by

            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 Reply Quote 0
            • G
              giesbert last edited by

              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 Reply Quote 0
              • First post
                Last post