title: Custom PyQt MultiSelection Dropdown in python
body: <p>Been using <a href="https://github.com/spanners/pyqt4-examples/blob/master/MultiSelectionExample/MultiCheckComboBox.py" rel="nofollow noreferrer">his</a> code for my application that I am developing I felt that the behavior is incomplete so I've added some codes to make the behavior fit to what I am developing but the problem is that I can't seem to add the behavior of when I clicked it again it will close not reload.</p>
  
  <p>First I added this line <code>self.visible=False</code> in the <code>ini</code> function since I don't know how to check whether the the dropdown is open.</p>
  
  <p>Second is I modified line <code>319</code> to:</p>
  
  <pre><code>if obj == self._lineEdit:
         if self.visible:
              self.visible = False
              self.hidePopup()
          else:
              self.visible = True
              self.showPopup()
  </code></pre>
  
  <p>This works IF you click the dropdown again but when I click outside of the dropdown to close the dropdown it does not open until you click it twice</p>
  
  <p>I also tried to modify some of the events but I quickly found out that when I click to close the dropdown the <code>QEvent.MouseButtonPress</code> in line <code>291</code> triggers twice.</p>
  
  <p>Current behavior:</p>
  
  <ul>
  <li>if I clicked the dropdown, dropdown opens</li>
  <li>if I clicked the dropdown again, dropdown closes</li>
  <li>if the dropdown is open and I clicked outside of the dropdown, dropdown closes</li>
  <li>if I clicked the dropdown after closing it by clicking outside, dropdown does not open until second click (My Problem)</li>
  </ul>
  
  <p>How can I make it so that when the dropdown is clicked it will open and close properly even if I clicked outside.</p>