Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved Window geometry

    General and Desktop
    2
    14
    252
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • SPlatten
      SPlatten last edited by

      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?

      jsulm 1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @SPlatten last edited by

        @SPlatten https://doc.qt.io/qt-5/qmainwindow.html#centralWidget

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 1
        • SPlatten
          SPlatten last edited by

          @jsulm , ok thats for a QMainWindow, is it also valid for a QWindow?

          jsulm 1 Reply Last reply Reply Quote 0
          • jsulm
            jsulm Lifetime Qt Champion @SPlatten last edited by

            @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.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 0
            • SPlatten
              SPlatten last edited by

              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.

              jsulm 1 Reply Last reply Reply Quote 0
              • jsulm
                jsulm Lifetime Qt Champion @SPlatten last edited by

                @SPlatten said in Window geometry:

                as I am defining my widget as QWindow that it cannot be cast to a QMainWindow

                Of course not

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply Reply Quote 0
                • SPlatten
                  SPlatten last edited by

                  So my original question still stands how to get the geometry of the area inside the frame? I'm currently looking at frameMargins.

                  jsulm 1 Reply Last reply Reply Quote 0
                  • jsulm
                    jsulm Lifetime Qt Champion @SPlatten last edited by jsulm

                    @SPlatten As I said above: according to the documentation QWindow::geometry() should not contain window frame.
                    Where do you call geometry()? I hope not in constructor.

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply Reply Quote 0
                    • SPlatten
                      SPlatten last edited by

                      No, from the eventFilter:

                      bool clsXMLnode::eventFilter(QObject* pobjObject, QEvent* pobjEvent) {
                          if ( pobjEvent->type() == QEvent::Resize ) {
                          ....
                          }
                          return QObject::eventFilter(pobjObject, pobjEvent);
                      }
                      
                      jsulm 1 Reply Last reply Reply Quote 0
                      • jsulm
                        jsulm Lifetime Qt Champion @SPlatten last edited by

                        @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()."

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply Reply Quote 0
                        • SPlatten
                          SPlatten last edited by

                          I'm want the inner size so I can use it when the window is resized.

                          jsulm 1 Reply Last reply Reply Quote 0
                          • jsulm
                            jsulm Lifetime Qt Champion @SPlatten last edited by

                            @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.

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply Reply Quote 0
                            • SPlatten
                              SPlatten last edited by

                              From the geometry I can see it includes the title area.

                              1 Reply Last reply Reply Quote 0
                              • SPlatten
                                SPlatten last edited by SPlatten

                                This post is deleted!
                                1 Reply Last reply Reply Quote 0
                                • First post
                                  Last post