Results 1 to 4 of 4

Thread: Native parent window for QWidget (IPreviewHandler)

  1. #1
    Join Date
    Jan 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Native parent window for QWidget (IPreviewHandler)

    Hi there!

    I am currently trying to make a shell extension preview handler with Qt. The code I work with is based on the Recipe Preview Handler + ActiveQt. Everything works fine except the creation of the preview window.

    I need to create a widget which has a native window (HWND/WId) parent. I have looked in the QWidget documentation but I didn't found anything.

    My Question is: Is it possible to create a widget which has a native window as parent?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Native parent window for QWidget (IPreviewHandler)

    A top level window is always a native window. You can get a handle to it by calling winId().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jan 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Native parent window for QWidget (IPreviewHandler)

    Okay I am one step futher, but the widget is showed in a own window rather than in the preview frame.

    This is the code I have:
    Qt Code:
    1. HRESULT PreviewHandler::DoPreview()
    2. {
    3. HRESULT hr = E_FAIL;
    4. if (previewWidget.isNull() && _pStream) // cannot call more than once (Unload should be called before another DoPreview)
    5. {
    6. previewWidget.reset(new PreviewWidget());
    7. ::SetParent((HWND)previewWidget->winId(), _hwndParent);
    8. ShowWindow((HWND)previewWidget->winId(), SW_SHOW);
    9. //previewWidget->show(); //Same effect
    10. }
    11. return hr;
    12. }
    To copy to clipboard, switch view to plain text mode 

    So how can I show the widget as child rather than in a own window?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Native parent window for QWidget (IPreviewHandler)

    I don't think you can do that without some special tricks. The best that comes to my mind is to render the widget to an image and then draw that image to the preview window using WinAPI calls.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Embedding native UI in a QWidget?
    By Thuan Seah Tan in forum Qt Programming
    Replies: 5
    Last Post: 5th December 2013, 11:09
  2. Replies: 5
    Last Post: 17th September 2013, 07:45
  3. Replies: 5
    Last Post: 21st April 2010, 22:36
  4. Promoting the parent QWidget of a QWidget form
    By extrakun in forum Qt Tools
    Replies: 6
    Last Post: 16th April 2010, 15:19
  5. Replies: 11
    Last Post: 4th June 2008, 08:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.