Qt/Qml integration


photo

Recommended Posts

Hi,

we are trying to integrate Unigine with Qt/Qml.

On windows using DX11 it work perfectly but on linux with opengl it doesn't work.

We have an Unigine viewport and some Qml widget (Qt5QuickWidgets) created dynamically, when a qml widget is created both Unigine and Qt stop refreshing with the following error :

 

OpenGL error: invalid operation

 

 

Any help would be appreciated.

You can reproduce it easily editing the source code of source/app/main_qt : (.zip with complete source code provided)

 

main_qt.pro :

--------------------------------

 

QT += core gui widgets quickwidgets

 

main_qt.cpp :

--------------------------------

 

// Qt

#include "MainWindow.h"

#include <QApplication>

#include <QDesktopWidget>

#include <QQuickWidget>

#include <QQuickView>

 

(...)

 

int main(int argc, char *argv[])

{

// Qt part

QApplication app(argc, argv);

MainWindow window;

 

    QQuickWidget *view = new QQuickWidget;

    view->setSource(QUrl::fromLocalFile("test.qml"));

    view->show();

 

// UnigineApp

AppQt *widget = NULL;

 

(...)

 

test.qml : (drop it in the main_qt folder)

--------------------------------

 

import QtQuick 2.0

 

Item {

 

 

width: 600

height: 400

 

Rectangle {

 

id: r

anchors.centerIn : parent

width: parent.width /2

height: parent.height /2

color: "red"

}

 

    Timer {

        interval: 1000; running: true; repeat: true

        onTriggered: {

console.log("Triggered " + r.color)

r.color = (r.color == "#ff0000") ? "blue" : "red"

}

}

}

 

main_qt.zip

Link to post

Hi Christophe,

 

The first version of our QML integration you can find in attachment. You need to change path to the SDK in QML.pro and main.qml to get it working on your side.

 

Before launch from QtCreator set working directory to <SDK>/bin (or <SDK>/lib, if you are using 2.3.1 SDK).

 

Currently input is send directly to QML.

 

Thanks!

QML.zip

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to post
  • 2 weeks later...
Hi,

Thanks for the integration ! It works without problem with Unigine 2.4 and Qt5.8 ..

Just one question ... Are you planning to add the events (mouse, keyboard, ...) ?

We are really interested in using this sample of code but we are wondering if you are working on it or if we improve it ourself ..

 

Thanks,

 

Christophe

Link to post