title: PyQt: How to scroll to right in a QListWidget?
body: <p>In a PyQt QListWidget I drag and drop files with their full path. Now I want the scrollbar to scroll to the right everytime I drag something in.
  However, there seems to be only <code>scrollToTop()</code> and <code>scrollToBottom()</code>, but I couldn't find <code>scrollToLeft()</code> or <code>scrollToRight()</code> or anything similar. Right alignment of the list items' text does not help, apparently I need to scroll the horizontal scrollbar to the right.</p>
  <p>How can I automatically scroll to right, such that I see the filenames, <em>not</em> the beginning of the path?
  It must be a simple setting, but I haven't found helpful documentation or examples so far.</p>
  <p><strong>Code:</strong></p>
  <pre><code>import sys
  from PyQt5.QtGui import *
  from PyQt5.QtWidgets import QListWidget, QListWidgetItem, QApplication, QWidget, QAbstractItemView, QVBoxLayout
  
  class MyListWidget(QListWidget):
      def __init__(self, parent):
          super(MyListWidget, self).__init__(parent)
          # self.setDragDropMode(QAbstractItemView.InternalMove)
          self.setAcceptDrops(True)
  
      def dragEnterEvent(self, event):
          if event.mimeData().hasUrls() or event.mimeData().hasFormat(&quot;text/plain&quot;):
              event.acceptProposedAction()
          else:
              super(MyListWidget, self).dragEnterEvent(event)
  
      def dropEvent(self, event):
          if event.mimeData().hasUrls():
              for url in event.mimeData().urls():
                  item = QListWidgetItem(url.toLocalFile())
                  self.addItem(item)
              event.acceptProposedAction()
          elif event.mimeData().hasFormat(&quot;text/plain&quot;):
              self.addItem(event.mimeData().text())
          else:
              super(myListWidget,self).dropEvent(event)
          self.scrollToBottom()                            ### but I want scrollToRight()  !!! 
          
  
  class MyWindow(QWidget):
      def __init__(self):
          super().__init__()
          self.left = 50 
          self.top = 50
          self.width = 900
          self.height = 500
          self.initUI()
  
      def initUI(self):
          self.vbox = QVBoxLayout()
          self.lw_myList = MyListWidget(self)
          self.vbox.addWidget(self.lw_myList)
          self.setLayout(self.vbox)
          self.show()
  
  if __name__ == '__main__':
      app = QApplication(sys.argv)
      # app.setStyle(&quot;plastique&quot;)
      window = MyWindow()
      # window.show()
      sys.exit(app.exec_())
  </code></pre>
  <p><strong>Result:</strong></p>
  <p><a href="https://i.stack.imgur.com/78hjd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/78hjd.png" alt="enter image description here" /></a></p>