Results 1 to 3 of 3

Thread: What is the right sizepolicy for a Qlabel I want it to have only the size of text?

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default What is the right sizepolicy for a Qlabel I want it to have only the size of text?

    I have two labels added at third and fourth position of a hori. layout. I have a last spacerItem. (with expanding).
    I want two behaviors :
    1.- How to set and 'autoscale' prop for QLabel in order to it has only the width needed.
    2.- A layout policy to avoid the labels expand
    Now I see how they grows unnecesary.
    Any help ?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: What is the right sizepolicy for a Qlabel I want it to have only the size of text

    What have you tried?

  3. #3
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: What is the right sizepolicy for a Qlabel I want it to have only the size of text

    Excuse for this late answer.
    I have solved the problem using 'fixed' for labels.
    Now my problem is the QLineEdit widget. I cant get apply any valid hor. policy. I'd want a similar behavior to the Labels. (That is, a Qlabel automatic fixed width depending on the contents. )
    Can I do this ? Thanks
    Have I to write a custom QLineEdit widget with a code to calc the size depending on the contents ? (I'm affraid yes,isn't it? )
    Last edited by tonnot; 14th February 2012 at 08:20.

Similar Threads

  1. Replies: 1
    Last Post: 1st February 2010, 02:01
  2. Replies: 1
    Last Post: 2nd August 2008, 15:46
  3. adjust font size to QLabel-size
    By hunsrus in forum Qt Programming
    Replies: 0
    Last Post: 9th July 2008, 14:33
  4. QLabel, large, rich text, font size
    By TheKedge in forum Qt Programming
    Replies: 3
    Last Post: 5th February 2007, 11:56
  5. Replies: 1
    Last Post: 24th October 2006, 16:40

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.