Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Embed 3rd party application into QWidget
Qt 6.11 is out! See what's new in the release blog

Embed 3rd party application into QWidget

Scheduled Pinned Locked Moved Unsolved 3rd Party Software
1 Posts 1 Posters 687 Views 1 Watching
  • 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 Offline
    G Offline
    gonssoruiz
    wrote on last edited by gonssoruiz
    #1

    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
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved