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. QWidget in layout, geometry() not updated on resize
Forum Updated to NodeBB v4.3 + New Features

QWidget in layout, geometry() not updated on resize

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 2 Posters 2.1k Views 2 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #1

    Hi
    If i read geometry of widget in a layout its not reflecting its actual size.
    How can i get the actual x,y and width and height.
    From layout?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      When and how are you reading it ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      mrjjM 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        When and how are you reading it ?

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by mrjj
        #3

        @SGaist
        Hi
        After they are shown,
        First without layout, and draw the rects.
        Then apply layout in designer and run and replot.

        Effect can also be seen directly in Designer
        The geometry is frozen in values as soon as you add layout

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Do you have a small sample to reproduce that ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          mrjjM 1 Reply Last reply
          0
          • SGaistS SGaist

            Do you have a small sample to reproduce that ?

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by mrjj
            #5

            @SGaist
            Let me try make one.
            alt text
            alt text
            and then after applying layout in Designer

            alt text

            The code runs when Calc is pressed. So they are always visible.

            alt text
            with layout.

            I do the same in both cases:

             QList<QWidget*> widgets = parent->findChildren<QWidget*>();
              foreach(QWidget* widget, widgets) {
            
                qDebug() << widget->metaObject()->className() << "" << widget->isHidden();
                if (widget->isHidden()) continue;
                InfoShape s;
                QRect r = rect();// drawing area
                s.box =  widget->geometry(); // actual widget
            

            I first though the layout was not complete ( delayed) but it cant be case when triggering with button.

            1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              I do map coordinates to parent. It hits me that maybe layout would affect that.

              1 Reply Last reply
              0
              • mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #7

                Yep, sorry. geometry is updated, its was due to incorrect mapping from local/global when layout is involved.

                1 Reply Last reply
                4
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Glad you found out and thanks for sharing your findings :)

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  2

                  • Login

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