Home > Software design >  Manipulating SVG Data in PyQt QMainWindow setStyleSheet- function
Manipulating SVG Data in PyQt QMainWindow setStyleSheet- function

Time:09-27

I'm working on a UI in PyQt and I want to add a background-image to the MainWindow. Adding the Picture is not the problem, but if I run my code the image is shown multiple times...

Here is a short codesnipped:

    import sys
    from PyQt5.QtCore import *
    from PyQt5.QtWidgets import *
    from PyQt5.QtGui import *

    class BackgroundIssue(QMainWindow):
        def __init__(self, parent = None):
            super().__init__(parent)

            self.setWindowTitle(f'Background Issue')
            self.setMinimumSize(1000, 800)
            self.setStyleSheet("background-image: url(max.svg);")

    if __name__ == "__main__":
        app = QApplication(sys.argv)
        window = BackgroundIssue()
        window.show()
        sys.exit(app.exec_())

You can see my output here: centered background image

  • Related