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. Can i use windows API in Qt?
Forum Updated to NodeBB v4.3 + New Features

Can i use windows API in Qt?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 6.8k 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.
  • P Offline
    P Offline
    pratik041
    wrote on last edited by
    #1

    If yes, does it will work in all platform which Qt support or only windows?

    Pratik Agrawal

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      Yes, you can mix Windows API code and Qt code.
      No, it is not portable as the Windows API is naturally bound to the Windows platform. It might run on emulated environments (Wine, Crossover).

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pratik041
        wrote on last edited by
        #3

        It means it will not work on MAC and Linux. I have seen a function @QWidget::winId () const@.
        In documentation i have read about this function but i am not clear about its platform dependency. can you make it more clear?

        Pratik Agrawal

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lgeyer
          wrote on last edited by
          #4

          Qt is built on top of native system APIs (Windows SDK, Carbon, Cacao, ...). Each of these APIs use their own types of identifiers (HWND, HIViewRef, NSView, ...), whereas Qt provides a platform-independent identifier (QWidget*).

          If you now want to use platform-specific API you will have to use a platform-specific identifier - this it what QWidget::winId() does. It returns a platform-specific identifier (HWND on Windows, HIViewRef or NSView on Mac OS X, ...).

          As long as you pass this platform-specific identifier to platform-independent functions like QWidget::find() your application will remain portable. As soon as you pass it to a platform-specific function, for example GetWindowText(), your application is no longer platform-independent as the GetWindowText() function is part of the Windows SDK which is only available on Windows (but not on Mac OS X, ...).

          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