How to Center a Window on the Screen
-
Development Environment
- Linux Y410P 4.14.71-1-MANJARO #1 SMP PREEMPT x86_64 GNU/Linux
- Qt Creator 4.7.0
- Based on Qt 5.11.1 (GCC 8.2.0, 64 bit)
I use the wiki approach[1] to center the window which is a
QWidgeton the screen and Qt Creator show the following warning message.'availableGeometry' is deprecated: Use QGuiApplication::screens()I check the official document[2] and find
QGuiApplication::screens()will returnQList<QScreen *>.According the document of
QScreen Class[3], it providesgeometry()to returnQRect.So I try this code
auto screenGeometry = QGuiApplication::screens().first()->geometry();and it occurs the following error message.member access into incomplete type 'QScreen'And suggestion?
Thanks
References
-
@gapry said in How to Center a Window on the Screen:
member access into incomplete type 'QScreen'
QScreen is not known to the compiler (except that it knows that it's a class) - so you should include the header where the QScreen class is defined.
-
@gapry said in How to Center a Window on the Screen:
member access into incomplete type 'QScreen'
QScreen is not known to the compiler (except that it knows that it's a class) - so you should include the header where the QScreen class is defined.
Hi,
@Christian-Ehrlicher said in How to Center a Window on the Screen:
@gapry said in How to Center a Window on the Screen:
member access into incomplete type 'QScreen'
QScreen is not known to the compiler (except that it knows that it's a class) - so you should include the header where the QScreen class is defined.
@Christian-Ehrlicher Didn't you mean
where the QScreen class is used in your application? -
Hi,
@Christian-Ehrlicher said in How to Center a Window on the Screen:
@gapry said in How to Center a Window on the Screen:
member access into incomplete type 'QScreen'
QScreen is not known to the compiler (except that it knows that it's a class) - so you should include the header where the QScreen class is defined.
@Christian-Ehrlicher Didn't you mean
where the QScreen class is used in your application?@SGaist said in How to Center a Window on the Screen:
where the QScreen class is used in your application
Yes :)
@gapry : Please mark the thread as fixed