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. Could not make background image not to repeat
Forum Updated to NodeBB v4.3 + New Features

Could not make background image not to repeat

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 2.6k Views 1 Watching
  • 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.
  • A Offline
    A Offline
    autoasl
    wrote on last edited by
    #1

    I am puzzled why it did not use background-repeat to no-repeat. It kept appearing repeating in the both directions. Maybe you could catch something that I overlooked. Basically this works as background image and I was able to put controls over the image. I just need the image to be non-repeat.
    Here is the code as follows:

    class displayImage(QtWidgets.QDialog):

    def init(self,parent=None):
    super(displayImage, self).init()

        self.setGeometry(50,50,25,250)
    
        oImage = QtGui.QImage("C:/imagefilename.bmp")
        self.setStyleSheet("background-image: url(oImage); background-repeat: no-repeat; background-position: left;")
        
    
       
        
        # sImage = oImage.scaled(QtCore.QSize(75,250))                   # resize Image to widgets size
        
        palette = QtGui.QPalette()
        palette.setBrush(QtGui.QPalette.Window, QtGui.QBrush(oImage))
        self.setPalette(palette)
    
    J.HilkJ 1 Reply Last reply
    0
    • A autoasl

      I am puzzled why it did not use background-repeat to no-repeat. It kept appearing repeating in the both directions. Maybe you could catch something that I overlooked. Basically this works as background image and I was able to put controls over the image. I just need the image to be non-repeat.
      Here is the code as follows:

      class displayImage(QtWidgets.QDialog):

      def init(self,parent=None):
      super(displayImage, self).init()

          self.setGeometry(50,50,25,250)
      
          oImage = QtGui.QImage("C:/imagefilename.bmp")
          self.setStyleSheet("background-image: url(oImage); background-repeat: no-repeat; background-position: left;")
          
      
         
          
          # sImage = oImage.scaled(QtCore.QSize(75,250))                   # resize Image to widgets size
          
          palette = QtGui.QPalette()
          palette.setBrush(QtGui.QPalette.Window, QtGui.QBrush(oImage))
          self.setPalette(palette)
      
      J.HilkJ Online
      J.HilkJ Online
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @autoasl
      What version of qt are you using?


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      A 1 Reply Last reply
      0
      • J.HilkJ J.Hilk

        @autoasl
        What version of qt are you using?

        A Offline
        A Offline
        autoasl
        wrote on last edited by
        #3

        @J-Hilk
        I am a newbie. I am not quite sure but I believe I am using qt using PySide2 binding. I am using to develop GUI for Maya. That is the only way it got working.

        J.HilkJ 1 Reply Last reply
        0
        • A autoasl

          @J-Hilk
          I am a newbie. I am not quite sure but I believe I am using qt using PySide2 binding. I am using to develop GUI for Maya. That is the only way it got working.

          J.HilkJ Online
          J.HilkJ Online
          J.Hilk
          Moderators
          wrote on last edited by J.Hilk
          #4

          @autoasl
          Qt as a framework, comes in many different versions. (Also as bindings for python)

          you can simply print QT_VERSION to check at run time, I don't know how else you would check it as I'm not familiar with Python.
          something like this:

          int main(int argc, char *argv[])
          {
              QApplication a(argc, argv);
          
              qDebug() << QString::number(QT_VERSION,16); // Result will be 50C06 -> Qt 5.12.6
          
              return  a.exec();
          }
          

          I'm asking, because there was a bug with stylesheets, and those were not correctly applied to the widgets. That was fixed in the newest versions, 5.12.6 and 5.13.2


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          A 1 Reply Last reply
          1
          • J.HilkJ J.Hilk

            @autoasl
            Qt as a framework, comes in many different versions. (Also as bindings for python)

            you can simply print QT_VERSION to check at run time, I don't know how else you would check it as I'm not familiar with Python.
            something like this:

            int main(int argc, char *argv[])
            {
                QApplication a(argc, argv);
            
                qDebug() << QString::number(QT_VERSION,16); // Result will be 50C06 -> Qt 5.12.6
            
                return  a.exec();
            }
            

            I'm asking, because there was a bug with stylesheets, and those were not correctly applied to the widgets. That was fixed in the newest versions, 5.12.6 and 5.13.2

            A Offline
            A Offline
            autoasl
            wrote on last edited by
            #5

            @J-Hilk Yes I did something different for Python and Maya It appears that PySide2 uses PyQt5 5.6.1 binding

            J.HilkJ 1 Reply Last reply
            0
            • A autoasl

              @J-Hilk Yes I did something different for Python and Maya It appears that PySide2 uses PyQt5 5.6.1 binding

              J.HilkJ Online
              J.HilkJ Online
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              @autoasl said in Could not make background image not to repeat:

              PySide2

              Interesting, from the official side, it should be 5.12.6 🤔
              https://pypi.org/project/PySide2/

              I however, can not further help you, I'm sure someone else has more experience with Images as background Brush :)


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              A 1 Reply Last reply
              0
              • J.HilkJ J.Hilk

                @autoasl said in Could not make background image not to repeat:

                PySide2

                Interesting, from the official side, it should be 5.12.6 🤔
                https://pypi.org/project/PySide2/

                I however, can not further help you, I'm sure someone else has more experience with Images as background Brush :)

                A Offline
                A Offline
                autoasl
                wrote on last edited by
                #7

                @J-Hilk Thank you for pointing out what is the root cause. I'll try investigating more. I see one from the Internet "Maya 2019 uses Qt5.6.1 which is binary compatible with the latest version of PyQt 5.11.3 / SIP - 4.19.13" I may need to try upgrade if I can

                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