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/OpenGL in ApplicationWindow
Forum Updated to NodeBB v4.3 + New Features

QML/OpenGL in ApplicationWindow

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 956 Views 1 Watching
  • 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.
  • C Offline
    C Offline
    clarkm2
    wrote on last edited by
    #1

    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();@

    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