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. Size of QCheckBox
Forum Updated to NodeBB v4.3 + New Features

Size of QCheckBox

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 345 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.
  • S Offline
    S Offline
    stretchthebits
    wrote on last edited by
    #1

    Allo,
    In order to get the size of a text string, I do

    QString qstring;
    QRect rect;
    QCheckBox TheCheckBox;
    QFontMetrics *fm;
    fm=new QFontMetrics(pFONTSmallFont[0]);
    qstring=”A String”;
    rect=fm->boundingRect(qstring);
    width=rect.width();
    height=rect.height();
    TheCheckBox->setGeometry(x, y, width, height);
    

    but I think that width is not sufficient. What about the size of the box thing that appears to the left side?

    I guess I need a

    size=TheCheckBox->GetCheckBoxThingSize();
    TheCheckBox->setGeometry(x, y, size.width+width, size.height+height);
    
    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Set the string for your QCheckBox, call sizeHint/minimumSizeHint

      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
      • C Offline
        C Offline
        ChrisW67
        wrote on last edited by
        #3

        @stretchthebits Why are you manually trying to determine the size of widgets at all?

        S 1 Reply Last reply
        0
        • C ChrisW67

          @stretchthebits Why are you manually trying to determine the size of widgets at all?

          S Offline
          S Offline
          stretchthebits
          wrote on last edited by
          #4

          @ChrisW67 said in Size of QCheckBox:

          @stretchthebits Why are you manually trying to determine the size of widgets at all?

          I figure out their dimensions, I call setGeometry() for each so that the text fits in them since the user can change the text size that appears on Buttons, edit boxes, checkboxes, radio buttons, list boxes, labels. Also, I resize the window so that all these controls fit in.

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

            Use a proper layout instead...

            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
            0

            • Login

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