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.
  • M Offline
    M Offline
    mrjj
    Lifetime Qt Champion
    wrote on 15 Oct 2017, 20:40 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
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 15 Oct 2017, 20:43 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

      M 1 Reply Last reply 15 Oct 2017, 20:45
      0
      • S SGaist
        15 Oct 2017, 20:43

        Hi,

        When and how are you reading it ?

        M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 15 Oct 2017, 20:45 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
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 15 Oct 2017, 20:46 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

          M 1 Reply Last reply 15 Oct 2017, 20:49
          0
          • S SGaist
            15 Oct 2017, 20:46

            Do you have a small sample to reproduce that ?

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 15 Oct 2017, 20:49 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
            • M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 15 Oct 2017, 21:00 last edited by
              #6

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

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 15 Oct 2017, 21:03 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
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 15 Oct 2017, 21:05 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

                  1/8

                  15 Oct 2017, 20:40

                  • Login

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