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 QLabel border size ?
Qt 6.11 is out! See what's new in the release blog

How to get QLabel border size ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 3.2k 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.
  • AhtiA Offline
    AhtiA Offline
    Ahti
    wrote on last edited by Ahti
    #1

    I want to get border size of a QLabel object. I did a research online and found this https://stackoverflow.com/questions/27771357/qt-qlabel-border-size
    but it was not helpful. and i also wanna know the default border size of QLabel
    thanks

    what is a signature ?? Lol

    EddyE joeQJ 2 Replies Last reply
    0
    • AhtiA Ahti

      I want to get border size of a QLabel object. I did a research online and found this https://stackoverflow.com/questions/27771357/qt-qlabel-border-size
      but it was not helpful. and i also wanna know the default border size of QLabel
      thanks

      EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      @Ahti
      The default border size of QLabel is platform dependent. What OS are you on?

      What do you want to do with the border size?

      Qt Certified Specialist
      www.edalsolutions.be

      AhtiA 1 Reply Last reply
      1
      • AhtiA Ahti

        I want to get border size of a QLabel object. I did a research online and found this https://stackoverflow.com/questions/27771357/qt-qlabel-border-size
        but it was not helpful. and i also wanna know the default border size of QLabel
        thanks

        joeQJ Offline
        joeQJ Offline
        joeQ
        wrote on last edited by joeQ
        #3

        @Ahti Hi,friend,welcome.

        QLabel inherits QFrame. You should to see QFrame.

        such as,

        
        int QFrame::frameWidth() const
        int QFrame::lineWidth() const  ///< i think should use this
        
        

        try them.

        and default border size of QLabel maybe is 1

        Just do it!

        1 Reply Last reply
        0
        • EddyE Eddy

          @Ahti
          The default border size of QLabel is platform dependent. What OS are you on?

          What do you want to do with the border size?

          AhtiA Offline
          AhtiA Offline
          Ahti
          wrote on last edited by
          #4

          @Eddy
          Widows 10.
          I am trying to fit the text in the label by keep increasing the height and width of text until it reaches the width and height of label but if border size of label is extended would it come in the way of text which would cause to hide the part of text on the edges ?

          what is a signature ?? Lol

          1 Reply Last reply
          0
          • EddyE Offline
            EddyE Offline
            Eddy
            wrote on last edited by Eddy
            #5

            Hi Ahti,

            Are you using layouts?
            If you do the label will adapt automatically to the needed size of the text in the label. Qt does this for you by changing the sizehint based on the text space needed, you don't need to tinker with those details.

            You can try it out yourself : make a simple QDialog based test application. Put a QLabel in it. Add a layout and make the dialog size minimal by dragging it in Qt Designer. Then hit run.

            Then change the font size to something much bigger and run again. You will see the magic of Qt yourself. The program knows ther is more space needed and the dialog will adapt.

            This is very important when you make versions of your program in other languages. If the translation of your label text is longer. the label will inform it's parent and it will be bigger.

            More information about layouts can be found : in the docs

            Qt Certified Specialist
            www.edalsolutions.be

            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