Hi, On Thursday 10 Dec 2015 16:31:38 Axel Jäger wrote: > Hello Sean, > thank you for your help. Now I got it working. > > However, I have the feeling that although this works, this is not the proper > way to do what I want. What do you think? Is this a hack or is it the > proper way to draw an own item using OpenGL?
What is hackish about it? All we're doing is asking the window to not draw it's background color. This is a perfectly valid approach. Cheers, Sean > > Best regards, > > Axel > > -----Ursprüngliche Nachricht----- > Von: Interest [mailto:[email protected]] Im Auftrag von Sean > Harmer > Gesendet: Sonntag, 6. Dezember 2015 10:46 > An: [email protected] > Betreff: Re: [Interest] Draw own QQuickItem using OpenGL together with > QQuickApplicationEngine > > Hi, > > On 05/12/2015 23:28, Axel Jäger via Interest wrote: > > Hello, > > I am trying to start a new application and want to start with the most > > modern possible codebase so I am looking into different options. The > > application I want to develop consists of a large OpenGL-View togehter > > with some slider next to it to change some parameters of the view. I > > have a large experience in building widget based applications in Qt > > but just for the fun, I want to go for QML way. > > > > I found this example that shows how to combine OpenGL-Drawing with > > with > > QML-Items: > > > > http://doc.qt.io/qt-5/qtquick-scenegraph-openglunderqml-example.html > > > > Then I found the Qt Quick Controls template in QtCreator that uses > > QQuickApplicationEngine which seems even more sophisticated than just > > using a QQuickView with a QML-File as a root item. > > I tried adopting the first example to use QQuickApplicationEngine by > > changing the main-method according to the template and changed the > > main.qml to use ApplicationWindow instead of Item as the root object. > > The effect is that I see all the QML Items in a window but the custom > > opengl drawing is not displayed. I see from the debugger that the > > opengl drawing code is executed. > > > > > > Attached you will find my modified example. I guess that I just did > > something very stupid and the viewport of my custom opengl items is > > something like 0x0. > > I would be very happy if there was a an example that uses > > QQuickApplicationEngine to load a qml-file with an ApplicationWindow > > and that does some OpenGL drawing besides QtQuick based controlls. > > Any help is greatly appriciated. > > You're almost there. The clue is if you change the rendering to be done as a > result of the afterRendering() signal instead of beforeRendering() it > works. So that means the GL code is all fine. So, something must either be > clearing or drawing on top of your GL rendering. > > It turns out that the ApplicationWindow by default paints itself with the > widget colour. You can use a style to disable this like so: > > ApplicationWindow { > visible: true > width: 320 > height: 480 > style: ApplicationWindowStyle { > background: Item {} > } > > Squircle { ... } > > ... > } > > Then it works as expected. > > Cheers, > > Sean > > -- > Dr Sean Harmer | [email protected] | Managing Director UK KDAB (UK) Ltd, > a KDAB Group company Tel. +44 (0)1625 809908; Sweden (HQ) +46-563-540090 > Mobile: +44 (0)7545 140604 > KDAB - Qt Experts > > _______________________________________________ > Interest mailing list > [email protected] > http://lists.qt-project.org/mailman/listinfo/interest -- Dr Sean Harmer | [email protected] | Managing Director UK KDAB (UK) Ltd, a KDAB Group company Tel. +44 (0)1625 809908; Sweden (HQ) +46-563-540090 Mobile: +44 (0)7545 140604 KDAB - Qt Experts _______________________________________________ Interest mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/interest
