title: How do I make a context menu for each item in a QListWidget?
body: <p>I'm working on a QGIS plugin, where the UI is made with PyQt. I have a QListWidget and a function that fills it. I'd like to add a context menu for each item with only one option: to open another window.</p>
  
  <p>I'm having trouble searching for info, since most of it works only on PyQt4 and I'm using version 5. The QListWidget that I want to add a context menu on is <code>ds_list_widget</code>. Here's some of the relevant code.</p>
  
  <pre><code>FORM_CLASS, _ = uic.loadUiType(os.path.join(
      os.path.dirname(__file__), 'dialog_base.ui'))
  
  class Dialog(QDialog, FORM_CLASS):
      def __init__(self, parent=None):
          ...
          self.p_list_widget = self.findChild(QListWidget, 'projects_listWidget') 
          self.p_list_widget.itemClicked.connect(self.project_clicked)
          self.ds_list_widget = self.findChild(QListWidget, 'datasets_listWidget')        
          self.ds_list_widget.itemClicked.connect(self.dataset_clicked)
          ...
  
  
      def project_clicked(self, item):
          self.fill_datasets_list(str(item.data(Qt.UserRole)))        
          self.settings.setValue('projectIdValue', str(item.data(Qt.UserRole)))
  
      def fill_datasets_list(self, project_id):
          self.ds_list_widget.clear()
          dataset_list = self.anotherClass.fetch_dataset_list(project_id)
  
          for dataset in dataset_list:
              #Query stuff from remote
              ...
              item = QListWidgetItem(ds_name, self.ds_list_widget)
              item.setIcon(self.newIcon(ds_img))
              item.setData(Qt.UserRole, ds_id)
              self.ds_list_widget.addItem(item)
              self.ds_list_widget.setIconSize(self.iconSize)
  </code></pre>