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. How to get current size of QWidget placed in QGridLayout?
QtWS25 Last Chance

How to get current size of QWidget placed in QGridLayout?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.2k Views
  • 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.
  • clostridium_difficileC Offline
    clostridium_difficileC Offline
    clostridium_difficile
    wrote on last edited by
    #1

    Hello,
    How to get current size of QWidget placed in QGridLayout? Method width() and height() does not return correct values.

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

      Hi
      Just a note.
      Do not take width() and height() in the constructor of the widget holding the QGridLayout as resize/layout calculations are
      postponed until Widget is shown and might not have correct values yet.

      clostridium_difficileC 1 Reply Last reply
      3
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @clostridium_difficile said in How to get current size of QWidget placed in QGridLayout?:

        Method width() and height() does not return correct values.

        They should, please show us your code.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

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

          Hi
          Just a note.
          Do not take width() and height() in the constructor of the widget holding the QGridLayout as resize/layout calculations are
          postponed until Widget is shown and might not have correct values yet.

          clostridium_difficileC 1 Reply Last reply
          3
          • mrjjM mrjj

            Hi
            Just a note.
            Do not take width() and height() in the constructor of the widget holding the QGridLayout as resize/layout calculations are
            postponed until Widget is shown and might not have correct values yet.

            clostridium_difficileC Offline
            clostridium_difficileC Offline
            clostridium_difficile
            wrote on last edited by clostridium_difficile
            #4

            @mrjj said in How to get current size of QWidget placed in QGridLayout?:

            Hi
            Just a note.
            Do not take width() and height() in the constructor of the widget holding the QGridLayout as resize/layout calculations are
            postponed until Widget is shown and might not have correct values yet.

            Yeah, it worked! Thanks. Size of the widget is calculated AFTER placing it in the layout.

            1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #5

              @clostridium_difficile said in How to get current size of QWidget placed in QGridLayout?:

              Size of the widget is calculated AFTER placing it in the layout.

              How should it work otherwise :)

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              1

              • Login

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