Results 1 to 17 of 17

Thread: Events not fired when used Windows::SetParent on QApplication

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2009
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    2

    Default Re: Events not fired when used Windows::SetParent on QApplication

    Hi,

    I am a newbie to Qt, so please bear with me if I am asking silly questions. I am trying to perform SetParent on a child window which is a QApplication, but has no clue how to start. Therefore I am very interested in the code :

    HWND window = findEmbeddedWindow();

    Is it possible to paste some snipplet of the function findEmbeddedWindow() here? It will definitely be helpful to me. Thank you very much.

    Best Regards...

  2. #2
    Join Date
    Jun 2014
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Events not fired when used Windows::SetParent on QApplication

    I have a similar problem but exactly opposite -
    I too have a 'server' and a 'client' and I need to bring the client into the 'server's QWidget.

    my code is:
    Qt Code:
    1. winHandle = ::FindWindowA(NULL, "My Client");
    2. if(winHandle != NULL)
    3. {
    4. ::ShowWindow(winHandle, SW_HIDE);
    5.  
    6.  
    7. // Remove the window border
    8. LONG lStyle = GetWindowLong(winHandle, GWL_STYLE);
    9. lStyle &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU);
    10. ::SetWindowLong(winHandle, GWL_STYLE, lStyle);
    11.  
    12. ::SetParent(winHandle, (HWND)(ui->widget->effectiveWinId()));
    13. ::SetWindowPos(winHandle, HWND_TOP, ui->widget->pos().x(), ui->widget->pos().y(), 0, 0 , SWP_NOACTIVATE | SWP_FRAMECHANGED | SWP_NOSIZE | SWP_ASYNCWINDOWPOS);
    14. ::UpdateWindow(winHandle);
    15. ::ShowWindow(winHandle, SW_SHOW);
    16. }
    To copy to clipboard, switch view to plain text mode 
    the problem I'm facing is that sometimes (not always!) the servers' buttons become not responding.
    I noticed that when such a case happens, the buttons don't respond as long as they are located in the middle of the screen. but, the weirdest thing is that if i move the whole window so the buttons are located close to the edge of the screen - they work! if i move it back to the center - they stop working again.
    any idea?? someone?

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Events not fired when used Windows::SetParent on QApplication

    Have you tried using Qt's "foreign window" capability?

    QWindow::fromWinId() to create a QWindow for the winHandle and then embedding it into the widget scene using QWidget::createWindowContainer()

    Cheers,
    _

  4. #4
    Join Date
    Jun 2014
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Events not fired when used Windows::SetParent on QApplication

    can you explain exactly how to do so?
    I tried, but couldn't get the window to actually be embedded in the server's widget.
    the code I've tried was:
    Qt Code:
    1. QWindow* win= QWindow::fromWinId((WId)winHandle);
    2. QWidget *wid = QWidget::createWindowContainer(win,ui->widget);
    To copy to clipboard, switch view to plain text mode 
    the result I got was: the client's window shoed up small on the top left of the screen, not integrated at all.
    thanks!

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Events not fired when used Windows::SetParent on QApplication

    Did you add wid to the layout of its parent?

    Cheers,
    _

  6. #6
    Join Date
    Jun 2014
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Events not fired when used Windows::SetParent on QApplication

    no, how do you do so?

  7. #7
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Events not fired when used Windows::SetParent on QApplication

    Like for any other widget.

    If ui->widget does not have a layout yet, create a simple one and add the child widget

    Qt Code:
    1. QVBoxLayout *layout = new QVBoxLayout(ui->widget);
    2. layout->addWidget(wid);
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  8. #8
    Join Date
    Jun 2014
    Posts
    7
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Events not fired when used Windows::SetParent on QApplication

    thanks for that but it didn't work.
    I've realized that
    QWindow::fromWinId((WId)winHandle) returns NULL and in the console it found:
    fromWinId(): platform plugin does not support foreign windows.
    how can i solve this?

  9. #9
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Events not fired when used Windows::SetParent on QApplication

    Interesting. The Windows platform plugin should have the ForeignWindow capability.

    Which version of Qt are you using?

    Cheers,
    _

Similar Threads

  1. QObject::setParent across threads.
    By psih128 in forum Qt Programming
    Replies: 4
    Last Post: 21st January 2014, 16:01
  2. Replies: 2
    Last Post: 18th August 2011, 07:26
  3. Replies: 1
    Last Post: 15th August 2009, 11:23
  4. mouseMoveEvent during drag is not fired
    By gruszczy in forum Qt Programming
    Replies: 7
    Last Post: 24th February 2009, 21:04
  5. Qt widget setParent
    By bunjee in forum Qt Programming
    Replies: 9
    Last Post: 30th November 2007, 20:38

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.