Issue with QVBoxLayout while adding a QWebEngineView and QQuickView



  • I am trying to create e-reader with pages displayed by QWebEngineView and toolbar written in QML and displayed using QQuickView.

    Main.cpp

    include <QVBoxLayout>
    #include <QDesktopWidget>
    #include <toolbar.h>
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
        QDesktopWidget dw;
        WebEngineView *weView = new WebEngineView();
        weView->setGeometry(0,55,dw.width(),(dw.height()));
        QQuickView view;
        view.setSource(QUrl("qrc:/ReaderToolBar.qml"));
        view.setGeometry(0,0,dw.width(),50);
        view.setMinimumHeight(50);
        view.setMaximumHeight(50);
        QVBoxLayout *lay = new QVBoxLayout();
        lay->addWidget(QWidget::createWindowContainer(&view));
        lay->addWidget(weView);
        QWidget *wid = new QWidget();
        wid->setLayout(lay);
        wid->resize(dw.width(),dw.height());
        wid->show();
        return app.exec();
    }
    

    WebEngineView.qml

    #include "WebEngineView.h"
    WebEngineView::WebEngineView()
    {
    this->setUrl(QUrl("http://www.google.co.in"));
    }
    

    ReaderToolBar.qml

    import QtQuick 2.0
    
    Rectangle {
        id: tbrect
        width: 1200
        height: 50
        color: "transparent"
        visible: true
    
        MouseArea {
            anchors.fill: parent
            hoverEnabled: true
        }
    
        function showicons()
        {     
            libicon.visible = true
            tocicon.visible = true
       }
    Image {
            id: libicon
            x: 30
            smooth: true
            height: 36
            width: 36
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 8
            source: "qrc:/images/library.png"
            visible: true
    
            MouseArea {
                id: libiconma
                anchors.fill: parent
                onClicked: {
                    //rw.showlibrary()
                }
            }
        }
    
        Image {
            id: tocicon
            x: 90
            smooth: true
            height: 50
            width: 50
            anchors.bottom: parent.bottom
            //anchors.bottomMargin: 2
            source: "qrc:/images/toc.png"
            visible: true
    
            MouseArea {
                anchors.fill: parent
                onClicked: {
                    //rw.showtocinwebview();         
                }
            }
    Component.onCompleted: showicons()
    }
    

    Here the WebEngineView alone is displayed and the tool bar is not getting displayed.
    Let me know what I am missing so that tool bar is superimposed on the webenginview


Log in to reply
 

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