Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Window geometry
Forum Updated to NodeBB v4.3 + New Features

Window geometry

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 2 Posters 1.0k Views 1 Watching
  • 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.
  • SPlattenS SPlatten

    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?

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #2

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

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

    1 Reply Last reply
    1
    • SPlattenS Offline
      SPlattenS Offline
      SPlatten
      wrote on last edited by
      #3

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

      jsulmJ 1 Reply Last reply
      0
      • SPlattenS SPlatten

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

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #4

        @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
        0
        • SPlattenS Offline
          SPlattenS Offline
          SPlatten
          wrote on last edited by
          #5

          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.

          jsulmJ 1 Reply Last reply
          0
          • SPlattenS SPlatten

            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.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @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
            0
            • SPlattenS Offline
              SPlattenS Offline
              SPlatten
              wrote on last edited by
              #7

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

              jsulmJ 1 Reply Last reply
              0
              • SPlattenS SPlatten

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

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by jsulm
                #8

                @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
                0
                • SPlattenS Offline
                  SPlattenS Offline
                  SPlatten
                  wrote on last edited by
                  #9

                  No, from the eventFilter:

                  bool clsXMLnode::eventFilter(QObject* pobjObject, QEvent* pobjEvent) {
                      if ( pobjEvent->type() == QEvent::Resize ) {
                      ....
                      }
                      return QObject::eventFilter(pobjObject, pobjEvent);
                  }
                  
                  jsulmJ 1 Reply Last reply
                  0
                  • SPlattenS SPlatten

                    No, from the eventFilter:

                    bool clsXMLnode::eventFilter(QObject* pobjObject, QEvent* pobjEvent) {
                        if ( pobjEvent->type() == QEvent::Resize ) {
                        ....
                        }
                        return QObject::eventFilter(pobjObject, pobjEvent);
                    }
                    
                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    @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
                    0
                    • SPlattenS Offline
                      SPlattenS Offline
                      SPlatten
                      wrote on last edited by
                      #11

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

                      jsulmJ 1 Reply Last reply
                      0
                      • SPlattenS SPlatten

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

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #12

                        @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
                        0
                        • SPlattenS Offline
                          SPlattenS Offline
                          SPlatten
                          wrote on last edited by
                          #13

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

                          1 Reply Last reply
                          0
                          • SPlattenS Offline
                            SPlattenS Offline
                            SPlatten
                            wrote on last edited by SPlatten
                            #14
                            This post is deleted!
                            1 Reply Last reply
                            0

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved