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. Create my widget from HWND?
Forum Updated to NodeBB v4.3 + New Features

Create my widget from HWND?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 401 Views 2 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.
  • T Offline
    T Offline
    Taytoo
    wrote on last edited by
    #1

    I created a widget (MyWidget) window in QT Designer w/classes, it will show as an independent window on desktop without any parent, but I have to use an existing HWND to create the instance of MyWidget. Is it possible?

    Chris KawaC kshegunovK 2 Replies Last reply
    0
    • T Taytoo

      I created a widget (MyWidget) window in QT Designer w/classes, it will show as an independent window on desktop without any parent, but I have to use an existing HWND to create the instance of MyWidget. Is it possible?

      Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Taytoo said in Create my widget from HWND?:

      but I have to use an existing HWND to create the instance of MyWidget

      Sorry, but that doesn't make sense. You don't create widgets or windows using a HWND. HWND is a handle that you can get from an existing window. It's like a pointer in C++. You don't use pointers to create instances of classes. You can get a pointer to an existing instance.

      So if you have an existing HWND that means you have a native window. You can embed a widget inside that native window if you want. You would do that by getting the widget's HWND (using winId()) and then use native SetParent() to make the widget child of that existing window.

      1 Reply Last reply
      6
      • T Taytoo

        I created a widget (MyWidget) window in QT Designer w/classes, it will show as an independent window on desktop without any parent, but I have to use an existing HWND to create the instance of MyWidget. Is it possible?

        kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by
        #3

        @Taytoo said in Create my widget from HWND?:

        Is it possible?

        Not easily and involves some really nasty tricks. My advice: don't! See what @Chris-Kawa wrote, try to work around the issue. Why do you require this anyway?

        Read and abide by the Qt Code of Conduct

        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