Skip to content
QtWS25 Call for Papers
  • 0 Votes
    17 Posts
    2k Views
    W

    Looks like using the QProcess::stateChanged signal (and removing terminate()) works.
    It uses QThread::msleep() so its not ideal, but its fine for me.

    HWND myHWND; static BOOL CALLBACK enumWindowCallback(HWND hWnd, LPARAM lparam) { DWORD pid; GetWindowThreadProcessId(hWnd, &pid); if (pid == lparam) { myHWND = hWnd; return FALSE; } return TRUE; } ProgramStarter::ProgramStarter(QObject *parent) : QObject{parent} { QProcess *qpr = new QProcess(this); connect(qpr, &QProcess::stateChanged, this, [=](QProcess::ProcessState newState){ if (newState == QProcess::Running) { QThread::msleep(250); EnumWindows(enumWindowCallback, qpr->processId()); } }); QString executable = "C:\\path\\to\\program.exe"; qpr->start(executable); qDebug() << myHWND; }
  • 0 Votes
    2 Posts
    2k Views
    S

    Hello,
    I can only share my experiences. My "teacher" was this example. Yes, you can get HWND of window only. You should implement paint() method like example and render your content into the area occupied by the element. Area for rendering can be chosen as glViewport(x(), windowHeight - y() - height(), width(), height());. But (as I've understood) QQuickWindow has only two time for rendering: beforeRendering & afterRendering: it mean you can have only top or bottom rendered item.
    Then, I've found second way for rendering: render to FBO and draw as QQuickFramebufferObject. More information is here.