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. Aligning the text for a text label with the text in a QLineEdit
Forum Updated to NodeBB v4.3 + New Features

Aligning the text for a text label with the text in a QLineEdit

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 780 Views 2 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.
  • O Offline
    O Offline
    Omni_Philm
    wrote on last edited by
    #1

    Hello all,

    Title pretty much says it. I have a QLineEdit above a text label in a form layout. I am currently using a fixed pitch font and I would like the text in the text label to be aligned with the text in the QLineEdit.

    I have been trying to do this for a few days now to no avail. Would anyone have any ideas on how I can accomplish this?

    Thank you

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

      Hi
      What is wrong the things you tried?
      Seems only a pixel or so.
      alt text
      if you apply frame, its very close
      alt text

      1 Reply Last reply
      5
      • Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote on last edited by
        #3

        playing with a container for QLabel and setting padding as @mrjj said is the most direct solution but you could of course also write your own custom QLabel widget that paints the text bitmap whereever you want it inside the custom widget.

        I light my way forward with the fires of all the bridges I've burned behind me.

        1 Reply Last reply
        4
        • O Offline
          O Offline
          Omni_Philm
          wrote on last edited by
          #4

          Hello all,

          Thank you for your advice. I ended up placing the label into a container and adjusting the left margin padding. Set the value to 4 and everything appears to be lining up nicely. Thank you all for everything

          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