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 find the height and width of a QVBoxLayout / QHBoxLayout?
Forum Updated to NodeBB v4.3 + New Features

How to find the height and width of a QVBoxLayout / QHBoxLayout?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 4 Posters 6.5k 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.
  • M Offline
    M Offline
    MathSquare
    wrote on last edited by
    #1

    @int myBoxLayoutheight = ui->QBoxLayout->height
    int myBoxLayoutwidtht = ui->QBoxLayout->width@

    but that doesn't work, please help me ;)

    1 Reply Last reply
    0
    • A Offline
      A Offline
      akonradwesolutions
      wrote on last edited by
      #2

      This should be what you want:

      @
      QRect geometry = ui->QBoxLayout->contentsRect();
      int width = geometry.width();
      // ...
      @

      1 Reply Last reply
      0
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Unless you actually named it like that (which is quite misleading and not a good idea), QBoxLayout is a type, not a variable, -and width and height are funcions, not variables, so:-
        Scratch that, not enough coffee today :) contentsRect() is the way to go as previously stated.

        1 Reply Last reply
        0
        • H Offline
          H Offline
          Himanshu Rohilla
          wrote on last edited by
          #4

          You can use geometry() function of QBoxLayout .

          For Eg. :

          QRect geometry = ui->QBoxLayout->geometry();
          int width = geometry.width();
          int height = geometry.height();

          HImanshu Rohilla

          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