Attachment 'custommenu_signal.py'

Download

   1 #!/usr/bin/env python
   2 
   3 import sys
   4 from PyQt4.QtCore import Qt
   5 from PyQt4.QtGui import *
   6 
   7 app = QApplication([])
   8 tableWidget = QTableWidget()
   9 tableWidget.setContextMenuPolicy(Qt.CustomContextMenu)
  10 
  11 def openMenu(position):
  12 
  13     menu = QMenu()
  14     quitAction = menu.addAction("Quit")
  15     action = menu.exec_(tableWidget.mapToGlobal(position))
  16     if action == quitAction:
  17         qApp.quit()
  18 
  19 tableWidget.customContextMenuRequested.connect(openMenu)
  20 tableWidget.show()
  21 
  22 sys.exit(app.exec_())

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2014-06-07 00:03:50, 0.5 KB) [[attachment:custommenu_actions.py]]
  • [get | view] (2014-06-07 00:05:49, 0.3 KB) [[attachment:custommenu_actions_standard.py]]
  • [get | view] (2014-06-07 00:06:34, 0.5 KB) [[attachment:custommenu_signal.py]]
  • [get | view] (2014-06-07 00:03:23, 0.5 KB) [[attachment:custommenu_subclass.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.

Unable to edit the page? See the FrontPage for instructions.