QML/OpenGL in ApplicationWindow



  • I'm trying to integrate a C++/OpenGL QML component as a subwindow within the content area of an ApplicationWindow (QtQuickControls 5.3). This work is based on the "OpenGL Under QML" example in QT 5.3.1. My OpenGL rendering (3D Terrain) is working as expected, but the placement of the OpenGL viewport is affected by the height of the status bar as shown in the screenshots. This is causing problems when various views (QML, QPainter, OpenGL) with fixed size and position are loaded dynamically and widgets are anchored to the bottom of the view. This seems to be a internal problem, but maybe I'm missing something. Any help would be appreciated.

    (no statusbar)
    !http://i44.photobucket.com/albums/f20/clarkm2rpiclarkm2/a4aa38ee-f551-4f61-8821-57c021a816d2_zpsb00cdd74.png(no statusbar)!

    (with statusbar)
    !http://i44.photobucket.com/albums/f20/clarkm2rpiclarkm2/1e365ead-ca7f-45ca-bfe5-ef0bab2ac27f_zpsd107ab5f.png(large status bar)!

    @ApplicationWindow {
    visible: true
    id: appwin
    toolBar: BorderImage {
    id: toolbar
    width: parent.width
    height: 80
    source: "qrc:/images/toolbar.png"
    }
    statusBar: StatusBar {
    id: status
    height: 100
    }
    Item{
    width: parent.width/2
    height: parent.height
    anchors.left: parent.left
    Terrain{
    width: 512
    height: 512
    anchors.centerIn: parent
    //anchors.bottom: status.top
    }
    Rectangle {
    width: 512
    height: 512
    anchors.centerIn: parent
    color: Qt.rgba(1, 0, 0, 0.5)
    }
    }
    }@

    Relevant C++ code to setup viewport:
    @mWidth = mItem->width();
    mHeight = mItem->height();
    QPoint pt = mItem->window()->mapToGlobal(QPoint(0,0));
    mX = pt.x();
    mY = pt.y();
    ...
    glPushAttrib(GL_ALL_ATTRIB_BITS);
    glEnable(GL_SCISSOR_TEST);
    glViewport(mX, mY, mWidth, mHeight);
    glScissor(mX, mY, mWidth, mHeight);

    glClearColor(0.0f, 0.4f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    render();
    glDisable(GL_SCISSOR_TEST);
    glDisable(GL_DEPTH_TEST);
    glPopAttrib();@


Log in to reply
 

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