Results 1 to 3 of 3

Thread: background-image on QLabel does NOT work

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2007
    Posts
    209
    Thanks
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default background-image on QLabel does NOT work

    QLabel#logo {
    color: red;
    background-image: url(folder/logobackground.png);
    background-repeat: repeat-x;
    background-origin: content;
    }

    Ok I have a QLabel with ObjectName as "logo".
    I set the QLabel text to "boooooooooooooo" or some random text.
    Also keeping in mind that minimum size for this QLabel is 400 pixels wide.
    Now In CSS this would print logobackground.png on the QLabel about as many times as it can fit on the X-axis.

    However, after 2 hours of struggling, I find that QLabel does NOT support background-image, and the documentation must have a typo or something.

    I checked if it can find folder/logobackground.png at least 5 times so don't tell me I have wrong paths. I checked to make sure the Object name is there... in fact, the "boooooo" text does indeed become RED. But it seems QLabel does not support background-image attribute.

    And Just to prove to anyone who doubts my competence in being able to get the paths right etc here is a small application for you to try that proves that QLabel does not support background-image:
    Qt Code:
    1. QApplication app(argc, argv);
    2.  
    3. QLabel hello("Hello world!");
    4. hello.setObjectName("lol");
    5. app.setStyleSheet(QString("QLabel#logo { background-image: url(logobackground.png); }"));
    6. hello.resize(500, 80);
    7.  
    8. hello.show();
    To copy to clipboard, switch view to plain text mode 
    Last edited by VireX; 7th June 2007 at 21:48.

Similar Threads

  1. Dynamically changing QLabel background colour
    By T4ng10r in forum Qt Programming
    Replies: 19
    Last Post: 19th April 2007, 12:47
  2. background image in QTreeView
    By momesana in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2007, 06:25
  3. QLabel background color
    By munna in forum Newbie
    Replies: 3
    Last Post: 1st May 2006, 15:36
  4. Replies: 1
    Last Post: 5th April 2006, 16:44
  5. [QT4.1.1 XP] background image
    By incapacitant in forum Newbie
    Replies: 3
    Last Post: 1st March 2006, 13:02

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
  •  
Qt is a trademark of The Qt Company.