Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Why does background-image displays on top of background-color in QPushButton?
QtWS25 Last Chance

Why does background-image displays on top of background-color in QPushButton?

Scheduled Pinned Locked Moved Mobile and Embedded
2 Posts 2 Posters 2.2k 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.
  • M Offline
    M Offline
    mmesarina
    wrote on last edited by
    #1

    Hi,

    I set the stylesheet property of my MainWindow to load an image for the background of the window with setStyleSheet(), but that caused the QPushButtons in the entire project to display the same image as background, because I pressume setting the parent window's background-image property is automatically passed to the QPushButton's properties.
    So , since I wanted the buttons to show as background a color and not an image, I set the background-color of the QPushbuttons to a color, but the color shows behind the image.
    Can someone tell me how I could solve this problem.
    I just want my buttons to show a background color not an image, but setting the background-image property on the MainWidnow makes the buttons adopt the image.

    thank you

    -Malena

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      Hi,

      I assume, that the style sheet is incorrect.

      if you set a a "selector":http://doc.qt.nokia.com/4.7/stylesheet-syntax.html only widgets which fit thge selector get the property.

      e.g.

      @
      QTextEdit, QListView
      {
      background-image: url(draft.png);
      }
      @

      sets the beckground image to all QTextEdit, QListView and from those classes derived classes.

      @
      QWidget
      {
      background-image: url(draft.png);
      }
      @

      sets the beckground image to all QWidget derived classes, which means to all widgets.

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      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