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. OpenGL Content under SplitView
Forum Updated to NodeBB v4.3 + New Features

OpenGL Content under SplitView

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

    Hello guys

    based on This SplitView is a layout that will split contents and separate them with a draggable splitter

    I used This to load OpenGL Content in QML

    But something weird happened
    and SplitView don't Split the 3D Contents in separated layout

    Image: (as you can see OpenGL content is underneath all SplitView)

    9cf75f26-c867-4c9a-8938-ba61ca55757c-image.png

    It should be placed in the left side of the SplitView
    In the right side I have a transparent Rectangle

    as you can see the Note Rectangle and Text are in right layout but the OpenGL is not

    Code: main.qml

    
    import QtQuick 2.13
    import QtQuick.Controls 2.13
    
    Item {
        id: main
        width: 720
        height: 600
        
        SplitView {
            id: splitView
            anchors.fill: parent
    
            handle: Rectangle {
                implicitWidth: 4
                implicitHeight: 4
                color: SplitHandle.pressed ? "#81e889"
                    : (SplitHandle.hovered ? Qt.lighter("#c2f4c6", 1.1) : "#c2f4c6")
            }
    
            GL {
                implicitWidth: 250
            }
            
            Rectangle {
                implicitWidth: 350
                SplitView.minimumHeight: 250
                color: Qt.rgba(0.0, 1.0, 0.0, 0.1)
                Text {
                    anchors.fill: parent
                    wrapMode: Text.WordWrap
                    text: "Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello "
                }
            }
        }
    }
    

    GL type is another GL.qml

    import QtQuick 2.13
    import OpenGLUnderQML 1.0
    
    Item {
        id: lView
    
        Squircle {
            anchors.fill: parent
            SequentialAnimation on t {
                NumberAnimation { to: 1; duration: 2500; easing.type: Easing.InQuad}
                NumberAnimation { to: 0; duration: 2500; easing.type: Easing.InQuad}
                loops: Animation.Infinite
                running: true
            }
        }
    
        Rectangle {
            color: Qt.rgba(1, 1, 1, 0.7)
            radius: 5
            border.width: 1
            border.color: "white"
            anchors.fill: label
            anchors.margins: -10
        }
    
        Text {
            id: label
            color: "black"
            wrapMode: Text.WordWrap
            text: "The background here is a squricle rendered with raw OpenGL using the 'beforeRender()' signal in QQuickWindow. This text label and its border is rendered using QML"
            anchors.right: parent.right
            anchors.left: parent.left
            anchors.bottom: parent.bottom
            anchors.margins: 20
        }
    }
    

    OpenGLUnderQML come from https://doc.qt.io/qt-5/qtquick-scenegraph-openglunderqml-example.html

    and this is main.cpp

    #include <QtQuick/QQuickView>
    #include <QtWidgets/QApplication>
    #include <QtCore/QUrl>
    #include <QtQml/QtQml>
    
    #include "squircle.h"
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
    
        qmlRegisterType<Squircle>("OpenGLUnderQML", 1, 0, "Squircle");
    
        QQuickView view;
        view.setResizeMode(QQuickView::SizeRootObjectToView);
        view.setSource(QUrl("qrc:/main.qml"));
        view.show();
    
        return app.exec();
    }
    

    I don't know it is related to the way OpenGL content is rendered? or it should be behave like an Item (like Rectangle) after registering?!

    Would be appreciated for any help

    thanks

    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