Can QQuickWidget create a window by QML Window Element?



  • i use qquickwidget load a qml file, in the qml file i use a window element,
    but the window element not show.
    i don`t konw why, who can help me,thanks.

    (english is not good - -!)



  • @Felix.su
    It is hard to figure out the reason without your source code...!
    A Window is not visible by default, did you set the visible property ?

    Window{
      visible:true
    }
    


  • @Charby
    my source:

    
    // mainwin.cpp
    MainWin::MainWin():QQuickWidget()
    {
        setWindowFlags((Qt::FramelessWindowHint)
                           | (Qt::X11BypassWindowManagerHint)
                           | (Qt::Widget)
                           | (Qt::Window)
                 );
        setBaseSize(800,600);
        setResizeMode(QQuickWidget::SizeRootObjectToView);
        setSource(QUrl(QStringLiteral("../test/main.qml")));
    
    }
    // main.cpp
        QApplication app(argc, argv);
        MainWin w;
        w.show();
    
        return app.exec();
    // main.qml
    import QtQuick 2.5
    import QtQuick.Window 2.2
    import QtQuick.Controls 1.4
    import QtQuick.Dialogs 1.2
    
    Rectangle {
        visible: true
        color:"green"
        width: 800
        height: 600
        MouseArea {
            anchors.fill: parent
            onClicked: {
    //            Qt.quit();
            }
        }
    
        Text {
            text: qsTr("Hello World")
            anchors.centerIn: parent
        }
        Button {
            text:"open a inner dialog"
            onClicked: {
                inner.visible = !inner.visible
            }
        }
    
        Window {
            id:inner
            visible: false
            flags:Qt.Dialog | Qt.FramelessWindowHint
            width: 100
            height: 80
            Text {
                anchors.centerIn: parent
                text:"i`m a inner dialog"
            }
        }
    
    }
    

    when i click button the id:inner window don`t show~~



  • This might be a bug. I encountered several bugs in the field of non-standard QtQuick windows. Try if your code works correctly when all FramelessWindowHints are removed. Btw: Are you on Linux, Windows or Mac OS? What graphics card do you use? Which graphics driver is installed?

    Edit: This might be related to https://bugreports.qt.io/browse/QTBUG-33481



  • @Wieland thank you .
    i removed all FramelessWindowHints buy the window still not show.
    i`m on windows8.1 with Intel(R) HD Graphics.

    so.i mush wait for [https://bugreports.qt.io/browse/QTBUG-33481] fixed?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.