Results 1 to 4 of 4

Thread: QLabel ScaledContents ignored by style sheet?

  1. #1
    Join Date
    Jun 2007
    Posts
    62
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QLabel ScaledContents ignored by style sheet?

    I've got a QLabel. I want to display in it imageX.png. I edit the QLabel in Qt Designer.

    Say I set the QLabel to a SizePolicy of Fixed Fixed, and I set the geometry, the MaximumSize and the MinimumSize to 50 x 50. Suppose further than imageX.png has a dimension of 100 x 100.

    Finally set the QLabel's ScaledContents attribute to True.

    If I insert imageX.png into my *.qrc resource file, and set the Pixmap property of my QLabel to use the resource, everything works fine. The image appears as 50 x 50.

    However, if I clear the Pixmap property of my QLabel, and connect to the form a *.qss style sheet that sets the QLabel's background-image attribute with a url containing a file path to imageX.png on my hard drive, it does not work. The image appears as 100 x 100, clipped in a 50 x 50 QLabel.

    An I doing something wrong? Or do QLabel pixmaps set by style sheets ignore the ScaledContents attribute?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QLabel ScaledContents ignored by style sheet?

    background-image doesn't scale by itself. It's exactly the same with CSS. The pixmap property of the label and background-image style attribute are two completely different things.

  3. #3
    Join Date
    Jun 2007
    Posts
    62
    Thanks
    28
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Re: QLabel ScaledContents ignored by style sheet?

    I don't suppose there is a qss style sheet element that will allow one to change a QLabel's pixmap property, is there?

    I didn't think so.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QLabel ScaledContents ignored by style sheet?

    No, there is nothing like that. But you can use the resource system to fetch the pixmap and simply replace the resource set with another one when you want another graphics set (of course this won't affect existing widgets).

Similar Threads

  1. Style Sheet speed
    By ^NyAw^ in forum Qt Programming
    Replies: 1
    Last Post: 24th January 2008, 18:40
  2. Style Sheet on QWizard
    By desch in forum Qt Programming
    Replies: 2
    Last Post: 6th December 2007, 17:12
  3. QToolButton and Style sheet
    By desch in forum Qt Programming
    Replies: 8
    Last Post: 1st December 2007, 08:38
  4. Vertical Scroll Bar - Style Sheet
    By vishesh in forum Qt Programming
    Replies: 2
    Last Post: 18th September 2007, 19:03
  5. Qt 4.3 Style sheet, new features
    By Angelo Moriconi in forum Qt Programming
    Replies: 2
    Last Post: 12th June 2007, 15:22

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.