Window geometry
-
I'm calling geometry on a window it looks like the rectangle includes everything including the title bar. Is there a function or facility to return just the geometry of the inner window canvas?
-
@SPlatten According to https://doc.qt.io/qt-5/qwindow.html#geometry "Returns the geometry of the window, excluding its window frame". So, the frame should not be part of geometry.
-
I've tried the following:
QWidget* pobjWidget = pobjParent->pobjGetWidget(); if ( pobjWidget != nullptr ) { QMainWindow* pobjMainWindow = static_cast<QMainWindow*>(pobjWidget); QWidget* pobjCentral = pobjMainWindow->centralWidget();
And single stepped using the debugger, it will not step over centralWidget() which leads me to believe that as I am defining my widget as QWindow that it cannot be cast to a QMainWindow.
-
I've tried the following:
QWidget* pobjWidget = pobjParent->pobjGetWidget(); if ( pobjWidget != nullptr ) { QMainWindow* pobjMainWindow = static_cast<QMainWindow*>(pobjWidget); QWidget* pobjCentral = pobjMainWindow->centralWidget();
And single stepped using the debugger, it will not step over centralWidget() which leads me to believe that as I am defining my widget as QWindow that it cannot be cast to a QMainWindow.
@SPlatten said in Window geometry:
as I am defining my widget as QWindow that it cannot be cast to a QMainWindow
Of course not
-
So my original question still stands how to get the geometry of the area inside the frame? I'm currently looking at frameMargins.
-
No, from the eventFilter:
bool clsXMLnode::eventFilter(QObject* pobjObject, QEvent* pobjEvent) { if ( pobjEvent->type() == QEvent::Resize ) { .... } return QObject::eventFilter(pobjObject, pobjEvent); }
@SPlatten https://doc.qt.io/qt-5/qwidget.html#resizeEvent
"When resizeEvent() is called, the widget already has its new geometry. The old size is accessible through QResizeEvent::oldSize()." -
@SPlatten But how do you know that you get size including window frame?
Qt documentation clearly states that geometry() returns the size without window frame.
And what I wanted to say with my previous post: if you call geometry() in resize event you get new size, not old.