Important: Please read the Qt Code of Conduct -

Help needed with embedding an application in Qt application

  • Hello,

    I've tried to embed a Windows application in Qt application.
    I've used the following code to do that:
    wind = FindWindow("some class", "some window");
    QWindow* w = QWindow::fromWinId(reinterpret_cast<WId>(wind));
    QWidget* window = QWidget::createWindowContainer(w);

    I've used QTimer to sample the existence of the window and embed it into my QMainWindow whenever it is being opened.

    The problem is when I'm using the controls of the embedded window (it's a tabbed display based on WIndows API), it's not being redrawn automatically.

    Can anyone help me with that?

    Best regards,

  • Moderators

    Never tried anything like this, but maybe setting QWidget::DrawChildren in the container widgets RenderFlags?

    Just a complete guess though. Can you test with something else? Make sure it's not something that the application you are embedding is doing. I.e. use notepad or better yet another simple Qt app. There is a notepad like example in the Qt examples folder.

  • Hey,

    I've tried that, but it's not working.
    I think the problem is much deeper and the WinAPI application is not receiving the signals (messages) it is supposed to from the qt application, since I see that it doesn't react to the function keys being pressed as well.

  • Moderators


    There are unfortunately some issues with embedding external applications in Windows. Please add your issues to the comments at


    What is m_window?

    Why do you give window a parent without putting it in a layout?

  • Hi,

    Thanks for the link, I will post the issue there, however:

    1. It's a typo, it's supposed to be window
    2. I already removed that line, just one of the things I've tried. It is a part of a layout though as you can see there.

    I'm continuing to try and find a workaround this issue.
    I've reimplemented the nativeEvent() function in my QMainWindow inheriting class.
    I've tried to see which messages my application receives when I'm using the mouse in the embedded application and from what I've seen the problem is that the embedded application is constantly inactive and that's why it doesn't respond until I do something extreme as changing the layout forcing it redraw itself completely.
    Any ideas as to keep it active?

Log in to reply