Results 1 to 8 of 8

Thread: Changing QLineEdit's size

  1. #1
    Join Date
    Aug 2010
    Posts
    65
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Changing QLineEdit's size

    This is a pretty silly question, but it's one I can't find an answer in the documentation:

    How do I change the size of a QLineEdit. I know it's a "line"-edit and thus can only be one line long (which is why I chose it), but what I want to do is change its length. Currently it fits around fifteen characters, but I only need it to fit... two or three.

    I've tried QLineEdit::resize(), but that made no difference.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Changing QLineEdit's size

    Is the QLineEdit in a layout?
    If so, the layout will control its size.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Aug 2010
    Posts
    65
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Changing QLineEdit's size

    Indeed it is. How can I alter its size manually, though? The layout is clearly doing quite a poor job at it.

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Changing QLineEdit's size

    You can calculate the needed with using the font metrics and content margins and set a fixed size.

  5. #5
    Join Date
    Aug 2010
    Posts
    65
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Changing QLineEdit's size

    How do I do that, though? The only size-altering function I know is resize(), but that isn't changing anything.

  6. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Changing QLineEdit's size

    Ehm, then go to the documentation and search for "fixed" and "size" or "width" since that is what you want. You can also try the combination "fixedwidth".

    If you don't know how to turn your computer on, I can also help you with that


    Come on guys, dare to use the documentations search functions!

  7. #7
    Join Date
    Aug 2010
    Posts
    65
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Changing QLineEdit's size

    I searched for size-related functions like mad, going as far back as QObject. However, most of them seemed irrelevant to the case in hand.

    Also, I'm an idiot. >.>

  8. #8
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Changing QLineEdit's size

    So you have found (to leave at least one miracle ->)???::setFixedWidth()?

Similar Threads

  1. Replies: 3
    Last Post: 29th December 2008, 16:54
  2. Changing text colour of QLineEdit qss file
    By phillip_Qt in forum Qt Programming
    Replies: 2
    Last Post: 4th April 2008, 05:28
  3. prob with changing QLineEdit background color
    By Ahmad in forum Qt Programming
    Replies: 2
    Last Post: 30th April 2007, 12:44
  4. Dynamically changing QGroupBox size
    By T4ng10r in forum Qt Programming
    Replies: 5
    Last Post: 30th March 2007, 15:02
  5. changing the size of the tab width: QTabWidget
    By nikita in forum Qt Programming
    Replies: 2
    Last Post: 29th August 2006, 08:31

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.