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. [SOLVED] Detecting OS events for app switching (Windows, Mac, Linux) in Qt app? Detecting which application is running?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Detecting OS events for app switching (Windows, Mac, Linux) in Qt app? Detecting which application is running?

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

    Hello,

    I'm trying to make a cross platform Qt app which can detect when certain applications are run by the user (or already running) on the OS (e.g. Firefox and Google Chrome). It also needs to detect when the user switches focus from one app to another (switching from Firefox to Google Chrome).

    Question 1: I'd assume that the native OS environments have some means of achieving this through its API (e.g. Win32 API). But is there any I can achieve this through a Qt app? Any Qt wrapper class for this?

    Question 2: If I do have to resort to OS specific API or libraries, how exactly will I use that within my Qt app? What type of libraries would I need my Qt project? Will I need some sort of static linking? Or Dynamic linking?

    I'm new to Qt desktop application development and I'm not finding any documentation or examples of how to do this.

    Any help would be greatly appreciated.

    Thanks.

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

      Hi and welcome to devnet,

      1: There's no API in Qt for that

      2: That's up to you. You might even have the code directly in your application.

      Development using Qt follows the same principle as developing using any other framework. You only have some additional tools to use but it's nicely wrapped up for you.

      When you are saying to didn't find anything, what are you referring to ? Creating an application ? Building a library ?

      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
      • Q Offline
        Q Offline
        qt_sur
        wrote on last edited by
        #3

        Thanks @SGaist.

        With respect to #2 above, I wasn't too sure whether C/C++ Win32 header files (like windows.h) are just included by default in Qt 5.2.0 MinGW 32 bit. It seems that they are in fact included and I am hoping I can just use them directly without having to link any extra libraries?

        With respect to documentation/examples : I haven't used this type OS specific event handling before so I didn't really where to start exactly, especially with Qt apps. I will look around and update the thread accordingly when I find something. In the meantime, if anyone knows anything which might narrow down my searching time, feel free to comment :)

        Thanks again.

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

          It will all depend on what functions you will use, Windows.h is an "include everything and anything" kind of header. Don't count on it to be included systematically. When using windows specific function, include it or a more specific header.

          The best place to search for that kind of information is the Microsoft Developer Network (MSDN)

          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
          • Q Offline
            Q Offline
            qt_sur
            wrote on last edited by
            #5

            Thanks for the info @SGaist. I will edit this thread to be [SOLVED] for now since this is not really Qt specific and as you mentioned, I will be looking for more info at MSDN (and for Mac and Linux respectively).

            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