Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML's Native parent Window
Qt 6.11 is out! See what's new in the release blog

QML's Native parent Window

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 583 Views
  • 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.
  • J Offline
    J Offline
    JohnDaYe
    wrote on last edited by JohnDaYe
    #1

    I write a QML Window like this

    import QtQuick 2.9
    import QtQuick.Window 2.2
    
    Window {
        visible: true
        width: text1.width
        height: text1.height
        title: qsTr("Hello World")
        flags: Qt.FramelessWindowHint
        color: "#70000000"
        x: 0
        y: 0
        Text {
            id: text1
            x: 0
            y: 0
            text: "Hello World"
            color: "#FFFF0000"
        }
    }
    
    int main(int argc, char *argv[])
    {
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
        QGuiApplication app(argc, argv);
        QQuickView::setSceneGraphBackend(QSGRendererInterface::Software);
        QQmlApplicationEngine engine;
        engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    
        if (engine.rootObjects().isEmpty())
            return -1;
        QQuickWindow *pMainWnd = qobject_cast<QQuickWindow*>(engine.rootObjects()[0]);
        HWND hShowWnd = (HWND)pMainWnd->winId();
    
        DWORD dwStyle = GetWindowLong(hShowWnd, GWL_STYLE);
        SetWindowLong(hShowWnd, GWL_STYLE, dwStyle | WS_POPUP | WS_VISIBLE);
        DWORD dwExStyle = GetWindowLong(hShowWnd, GWL_EXSTYLE);
        SetWindowLong(hShowWnd, GWL_EXSTYLE, dwExStyle | WS_EX_TOOLWINDOW);
        HWND hWndParent = FindWindow(nullptr, TEXT("MFCApplication1"));
        SetParent(hShowWnd, hWndParent); //Windows API
        return app.exec();
    }
    

    it can not display on MFCApplication1 Window

    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