Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    4
    4
    4885
    Loading More Posts
    • 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
      MathSquare last edited by

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

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

      1 Reply Last reply Reply Quote 0
      • A
        akonradwesolutions last edited by

        This should be what you want:

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

        1 Reply Last reply Reply Quote 0
        • Chris Kawa
          Chris Kawa Moderators last edited by

          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 Reply Quote 0
          • H
            Himanshu Rohilla last edited by

            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 Reply Quote 0
            • First post
              Last post