Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Unsolved Embed 3rd party application into QWidget

    3rd Party Software
    1
    1
    380
    Loading More Posts
    • 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.
    • G
      gonssoruiz last edited by gonssoruiz

      Hi everyone,

      I've been struggling with a question for some time that seemed quite easy at the beginning.

      I want to embed an application (for example, Windows Calculator) into a QWidget. I've tried with this code:

      Widget.cpp

      Widget::Widget(QWidget *parent) : QWidget(parent)
      {
        QProcess::startDetached("c:\\windows\\system32\\calc.exe");
        HWND ID = FindWindowA(NULL, "Calculator");
      
        QWindow *Window = QWindow::fromWinId((WId)ID);
        Window->setFlags(Qt::FramelessWindowHint);
      
        QWidget *Widget = QWidget::createWindowContainer(Window);
      
        QVBoxLayout *Layout = new QVBoxLayout(this);
        Layout->addWidget(Widget);
        
        setLayout(Layout);
      }
      

      main.cpp

      int main(int argc, char *argv[])
      {
        QApplication a(argc, argv);
        Widget w;
        w.show();
      
        return a.exec();
      }
      

      The issue is that, although calculator opens, it shows behind every other window, and is placed in x:0, y:0 in screen.

      Does anyone has any idea why is happening this?

      Thanks

      1 Reply Last reply Reply Quote 0
      • First post
        Last post