QtQuick Controls not working correctly with custom QtQuick Items
-
Hi,
I've made my own opengl scene using Qt Quick as shown in the following example: http://qt-project.org/doc/qt-5/qtquick-scenegraph-openglunderqml-example.html and everything seems to work out fairly well using Qt 5.3.
I can add my own GUI elements in the qml file using Rectangles { ... }, but when I add Quick controls like buttons, the Qt Quick overlay elements does not seem to be drawn at all anymore.
If I comment out the scene overlay (called Squircle in the example), the GUI elements, including Buttons are shown correctly. There's no hints of issues or errors.This little addition to the QML file is all that is needed to break it such that the GUI overlay isn't displayed.
@ Button {
text: "Push Me"
anchors.centerIn: parent
}@So far I've made a mockup gui using my own custom controls through Rectangles, but now that I'm done with initial Qt Quick tests, I kinda want to take advantage of the core controls.
A couple of screenshots should make it more clear: http://imgur.com/2HiDXFD,rW23y2V#0
First picture shows the application when I've commented out the glscene (QQuick Item). Second image shows the application with the glscene and Quick overlay.Things I've so far tried: Using Z index to decide what elements is at bottom, resizing the opengl scene to a smaller portion in case the controls becomes hidden behind, change to Compatibility GL context instead of Core, running the application on Linux, Windows 7 and Android.
My Qt Quick knowledge is still fairly limited, so maybe there are some obvious things I should try?
-
There shouldn't really be anything special about the Controls themselves as they are simply Qt Quick Items. I am curious if you are using ApplicationWindow though, as I am pretty certain that will fill the background with gray by default, so you might want to see if setting the background color property to "transparent" makes a difference.
-
Unfortunately, I don't think the issue lies with transparency, or at least I couldn't find any change after setting properties like color transp / visible on ApplicationWindow or any controls within.
You're correct, I'm using ApplicationWindow. When I started out with Qt Quick and could not get the buttons to work, I was hoping things would get resolved by adopting a newer addition, thinking it might be required for the controls to work properly.
Curiously though, my Linux desktop build seem to outright crash (I couldn't remember that it did so yesterday, I've been working on windows since then). Considering that the crash could be related to ContextPrivate14maxTextureSize function, I'm gonna take a stab in the dark here and hope this asm stack call has something of value to someone.
http://imgur.com/YEuqWyVMy GPU is a Nvidia 560 TI, and while it's starting to get old, I wouldn't think I really had an issue with hardware limitations. My linux driver version is Nvidia 331.20.
-
Could you try using plain Window instead? There is nothing peculiar about ApplicationWindow with regard to controls unless you need to create top level menus which requires it. It could be that it incorrectly fills the background though.
-
By plain window, I assume you mean QML being wrapped into an Item { ... } element rather than ApplicationWindow , as well as using QQuickView to handle the window from the C++ side?
It did not change anything, but I notice that the clicked event fires off if I click where the button is supposed to be, so it's at least there, just seems like it becomes invisible or put behind the QQUickItem GL window.
The button works fine in the openglunderqml example, I copied the Squircle code over to my project and noticed that the button would still not draw unless I did not change the QSurfaceFormat like so:
@int main(int argc, char **argv)
{
QGuiApplication app(argc, argv);QSurfaceFormat format; format.setSamples(16); format.setOption(QSurfaceFormat::DebugContext); format.setMajorVersion(3); format.setMinorVersion(3); format.setProfile(QSurfaceFormat::CoreProfile); qmlRegisterType<Squircle>("SimpleLOS", 1, 0, "Overlay"); AppView view; view.setResizeMode(QQuickView::SizeRootObjectToView); view.setSource(QUrl("qrc:////content/gui/main.qml")); //view.setFormat(format); view.show(); return app.exec();
}@
Setting up my normal scene again without changing the QSurfaceFormat does not show the button, but at least I can be fairly certain that the issue has to be with the context or something similar.