EGLFS : OpenGL error while trying to open a new Window in QML
-
Hello, I have an app that consists of multiple plages. And user will be able to switch between these pages by button clicks. When I try to open my second window from the main window using:
Image { objectName: "background" width: parent.width height: parent.height source:"Imgs/Images/bckgnd.png" LeftButtons { id:buttonKontrol x: -20 y:110 buttonName: "kontrol" Loader { id: kontrolPageLoader} MultiPointTouchArea { id:touchArea_kontrol anchors.fill:parent onPressed: { kontrolPageLoader.source ="KontrolPage.qml" } } }
In the code above, KontrolPage is a window. Now I have some questions:
- Why I am getting EGLFS: OpenGL windows cannot be mixed with others error? And how can I solve it?
- Which way is better in order to open a new window, using C++ and QDeclarativeComponent or using QML and Loader?
- Why I try to open the new window by using QDeclarativeComponent it didn't let me #include <QDeclarativeEngine> also it gave not found module error when I try to add QT += declarative in my*.pro. Why it gives these errors?
Edit: After I change the Window { ..... } inside the Kontrolpage.qml to Item {.....} . Now with loader, it tries to open the other qml page. (Well it tries because when I press the button, it keeps opening and closing the other page. But doesn't really opening it completely..)
-
@Gunkut
i guess your Loader is jsut stacked behind your content?
change the z-value or move it infront of your content by placing it in the end of the elements code -
@Gunkut said in EGLFS : OpenGL error while trying to open a new Window in QML:
Why I am getting EGLFS: OpenGL windows cannot be mixed with others error? And how can I solve it?
EGLFS only supports a single window by design, no way around it.
Which way is better in order to open a new window, using C++ and QDeclarativeComponent or using QML and Loader?
There is no "better" per se. Depends on your project i would say.
Why I try to open the new window by using QDeclarativeComponent it didn't let me #include <QDeclarativeEngine> also it gave not found module error when I try to add QT += declarative in my*.pro. Why it gives these errors?
QDeclarativeComponent is QML1/Qt4 and not what you expect when you do
QT += declarative
with Qt5 -
@raven-worx Thanks raven so I put an Item instead of Window in the KontrolPage.qml and error is gone. When I use the above code new window gets the size of LeftButtons but I want to have it the size of Window. So I take Loader out of LeftButtons and put it in window{} as follows:
Window { id:main width:640 height:480 Loader { id: kontrolPageLoader anchors.fill:parent } Image { objectName: "background" width: parent.width height: parent.height source:"Imgs/Images/bckgnd.png" LeftButtons { id:buttonKontrol x: -20 y:110 buttonName: "kontrol" MultiPointTouchArea { id:touchArea_kontrol anchors.fill:parent onPressed: { kontrolPageLoader.source ="KontrolPage.qml" } } } }
In this way, loader does not open the new page. How can I find a way around?
PS: Sorry for bad indentation, code is in linux in virtual machine so I couldn't copy pasted it. -
-
@raven-worx Yes I have checked that document. My problem is not really about sizing but using in outside of Leftbuttons. I will have more than 1 page than I can open from the main page. So I need to put that Loader out of Leftbuttons. Otherwise I need to have more than 1 loader in each of the button widget.
-
@Gunkut
In Qt5 you can simply access the id of the loader (as long as it is in the same or parent context).
This should be avoided with Qt6. You can pass the loader as a property by id. (create property with type Loader/Item and pass assign the loader by its id to it. then you have a reference to the loader) -
@raven-worx I see but in QT5 using just id of the loader as pageLoader.source="KontrolPage.qml" does not really open the page. Nothing really changes I just put Loader in Leftbuttons {} and it works, when I put it in Image{} it does not open anything. Or maybe it opens it but size or coordiantes are really nonsense and I cannot see it on the screen?
-
@Gunkut
i guess your Loader is jsut stacked behind your content?
change the z-value or move it infront of your content by placing it in the end of the elements code -
@raven-worx Yes raven thank you. changin z- value worked.
-
@raven-worx In order to come back to main page from a page that I opened from loader. Should I use another loader in the new qml page or is there an easy and more appropriate way to come back main page. (like setting source=.). And the last question, can I have a loader in a page that is opened by a loader? Something like nested loaders? Sorry for too much questions but unfortunately QT docs are not really clear and detailed about QML as they are in QWidgets etc.
-
@Gunkut
i think you are better off by using a StackView element instead of a loader.
To push (a new page) into or pop (remove the current page) the StackView in which your current page/window currently is use the provided attached properties (e.g.StackView.view.push()
/StackView.view.pop()
)