PDA

View Full Version : QT-QML application: QQuickWindow to Full Screen: repaint failure ("bad window" in top



ddonate
20th October 2016, 17:32
Hi,

I have a Qt/QML application and I have a problem when setting the main window to Full Screen.

It goes Full Screen, but first it seems to be moved to the top-left corner of my screen. Then it changes to Full Screen, BUT this top-left window is there until I repaint my application. For instance, moving it to background and to foreground again.

I hope I am explaining properly...

In my code, I have a QWidget class where I create a QQmlApplicationEngine:

.h file:

QQmlApplicationEngine* m_pAppMainWindow;
QQuickWindow* m_pQuickWindow;

.cpp file:


m_pAppMainWindow = new QQmlApplicationEngine();

I use it to get app qml context

QQmlContext* pQmlContext = m_pAppMainWindow->rootContext();
to load the main QML file from resources:

m_pAppMainWindow->load(QUrl("qrc:/qml/ViewMain.qml"));
to set Image providers:

m_pAppMainWindow->addImageProvider(...);
and to get QQuickWindow object:

m_pQuickWindow = m_pQuickWindow = qobject_cast<QQuickWindow *>(m_pAppMainWindow->rootObjects()[0]);

I use the QQuickWindow object to set app window minimum size:

m_pQuickWindow->setMinimumWidth(...)
to get the QML objects to work with:

QObject* pObjViewMain = m_pQuickWindow->findChild<QObject*>("viewMain");
and to set app in full screen mode (on/off):

m_pQuickWindow->showFullScreen();
or
m_pQuickWindow->showNormal();

My problem is with this last point, when I enter Full Screen...

Hope anyone can help me

Thanks

anda_skoa
20th October 2016, 18:35
If you were to use a QQuickView you could try to use its resize mode to resize the content to the window's size.

Does your content follow the Window element's size changes?

Cheers,
_

P.S.: I shudder at the though of what "get the QML objects to work with" could mean

ddonate
20th October 2016, 18:43
Thanks anda_skoa,

My content follows the fullscreen change. In fact, the full screen over the QQuickWindow works, BUT this 'old size' window badly repainter over my new size in the the top-left (the app window seems to go there before applying the fullscreen mode)

I meant I use the QML objects from the c++ to access QML methods or properties

anda_skoa
20th October 2016, 22:16
My content follows the fullscreen change. In fact, the full screen over the QQuickWindow works, BUT this 'old size' window badly repainter over my new size in the the top-left (the app window seems to go there before applying the fullscreen mode)

I am afraid I don't understand then.
So when the app goes full screen, the content resizes nicely and all is well.
But when you switch back from full screen then the old, fullscreen content is still visible?



I meant I use the QML objects from the c++ to access QML methods or properties
Yes, that's what I though.
But you will learn soon enough that there are less hacky ways :)

Cheers,
_

ddonate
24th October 2016, 16:32
So when the app goes full screen, the content resizes nicely and all is well.
But when you switch back from full screen then the old, fullscreen content is still visible?
_

No, my problem is when going to fullScreen: The application size changes properly to full screen, but before changing the size, the old application window (with size previous to FS) seems to go to the top-left corner and it keeps there after the FS process is finished. So once the application is in FS, this window bad "frame" is like frozen there. When I repaint the application (for instance background and foreground again) this "frame" dissapears.



But you will learn soon enough that there are less hacky ways :)
_
Any suggestion to search? :)


Thanks a lot

anda_skoa
24th October 2016, 18:23
No, my problem is when going to fullScreen: The application size changes properly to full screen, but before changing the size, the old application window (with size previous to FS) seems to go to the top-left corner and it keeps there after the FS process is finished. So once the application is in FS, this window bad "frame" is like frozen there. When I repaint the application (for instance background and foreground again) this "frame" dissapears.

Hmm, strange. Doesn't the system trigger an update when the window goes fullscreen?



Any suggestion to search? :)


http://doc.qt.io/qt-5/qtqml-cppintegration-exposecppattributes.html

I.e. always prefer accessing C++ from the QML side over accessing QML from the C++ side.

Cheers,
_