Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

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

    Mobile and Embedded
    2
    2
    2024
    Loading More Posts
    • 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
      mmesarina last edited by

      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 Reply Quote 0
      • G
        giesbert last edited by

        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 Reply Quote 0
        • First post
          Last post