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. Background image question
Forum Update on Monday, May 27th 2025

Background image question

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 916 Views
  • 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.
  • J Offline
    J Offline
    Jeff Esposito
    wrote on last edited by
    #1

    I'm a Qt newbie, so maybe this is a dumb question...

    In QtDesigner, I set the centralWidget styleSheet propery to:

    border-image: url(:/QtOub/LogonBackground.jpg) 0 0 0 0 stretch stretch

    Then I added a groupbox the centralWidget with a few buttons and stuff.

    To my surprise, each widget (including the groupBox and each of its subwidgets) all have the image as their background.

    Ok, so apparently it "inherits" the background image from the centralWidget.

    So I set the groupBox's styleSheet property to "background-color: grey" thinking that it would clear the image to get a a plain grey backround for the groupBox. But I still see the images!

    Can someone explain what's going on and how to fix it?

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      that's why they are called cascading style sheets

      what you need to do is call setObjectName on the central widget to give it a unique name (say MyCentralWidget) and then set the stylesheet to

      #MyCentralWidget{border-image: url(:/QtOub/LogonBackground.jpg) 0 0 0 0 stretch stretch;}
      

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      1
      • J Offline
        J Offline
        Jeff Esposito
        wrote on last edited by
        #3

        Thanks, that did the trick!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved