QStackedWidget as 'window management' for embedded eglfs device?
-
It looks like you are trying to create something similar to QWizard::setField, isn't it ?
-
Not quite @SGaist, but not too dissimilar.
In short, I have a background function which runs multiple times a second to update the GUI elements on the screen (QWidgets, QLabels, QPixmaps, etc.). On the old version of the application, I could open a new window (Window.show()) and this function would continue to operate. Now that I've changed to QStackedLayout, this background function ceases when I call .setCurrentIndex(x) to change the window shown. I'm going through the code step-by-step at the moment, but I've set some print() commands at the key points in the application and it certainly appears that the .setCurrentIndex() is stopping the function.
-
I think I've found the culprit. On my multi-window version of the application, the updating of all GUI elements was driven by a paintEvent on the main QWidget, which is only on the main window. When I .show() a new window on top of the main window, calling .update() on this QWidget worked, and allowed for the updating of all QWidget, QLabels, etc., even if they were on a different window.
On the QStackedLayout application however, calling .update() doesn't work if the .currentIndex of the QStackedLayout doesn't have this main QWidget! So I'm calling .update() when changing between pages of the application, but the paintEvent() is only run when the .currentIndex() is on the main page.
-
I've separated the .painEvent() from the updating of the GUI elements on the other pages, and used a custom signal to paint the elements on the non-main page when .setCurrentIndex() is called. It's a bit of a workaround, but I'm much more comfortable now that I can tailor the updating of the separate page's GUI elements independent of the main page's main QWidget.
-
The paint event is not meant to trigger updates somewhere else.
What kind of update were you triggering and why in the paint event ?
-
Widget painting can happen for several reasons. For example because you are moving it, because you are moving something else on top of your application etc. Usually it won't happen only once.
-
I understand and agree, I was using the .update() call to force the paintEvent() and then change the colour/text of the other QWidgets/QLabels at the same time. It's all working nicely now that I've separated the paintEvent() from the GUI updating of the non-Main page QWidgets and QLabels :)
-
Great !
In that case, since you have everything working, please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found :)