QT 5.5 embed external application into QWidget

前端 未结 2 416
逝去的感伤
逝去的感伤 2020-12-14 04:37

I\'m interested in embedding an external application inside of my QT 5.5 Widget based application. I\'m only concerned with it working on Linux. I\'m using CentOS 7 with GN

相关标签:
2条回答
  • 2020-12-14 05:19

    The following achieves the desired result, the key was adding the FramelessWindowHint:

    QWindow *window = QWindow::fromWinId(211812356);
    window->setFlags(Qt::FramelessWindowHint);
    
    QWidget *widget = QWidget::createWindowContainer(window);
    
    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->addWidget(widget);
    this->setLayout(layout);
    
    0 讨论(0)
  • 2020-12-14 05:22

    You should have a look at this code: https://github.com/qtproject/qt-solutions/tree/master/qtwinmigrate/src

    It was designed to embed non-QT windows into a QWidget on Windows. But there may be some tricks you can pickup from here, like attributes they set to make the windows be nicely integrated with each other.

    For instance, you may try this (from qwinwidget.cpp):

    QEvent e(QEvent::EmbeddingControl);
    QApplication::sendEvent(widget, &e);
    

    If it does not help, check qwinwidget.cpp and qwinhost.cpp for other options.

    0 讨论(0)
提交回复
热议问题