QpushButton QTableWidget but when i add Menu action to button menu don't display why?

85 Views Asked by At

This is the code i want to run .

i put QpushButton in QTableWidget by setCellWidget but when i add Menu action to the button the menu doesn't display why?

  1.   p = QtWidgets.QPushButton("Test")
    
  2.    menuf= QtWidgets.QMenu(p)
    
  3.    p.setMenu(menuf)
    
  4.    Op= QtWidgets.QAction(menuf)
    
  5.    Pp= QtWidgets.QAction(menuf)
    
  6.    _translate = QtCore.QCoreApplication.translate
    
  7.    Op.setText(_translate("MainWindow", "Section"))
    
  8.    Pp.setText(_translate("MainWindow", "Charge"))
    
  9.    p.addAction(Op)
    
  10.    p.addAction(Pp)
    
  11.    self.tableWidget.setCellWidget(2,1,p)
    
  12.    thingWidget = self.tableWidget.cellWidget(2,1)
    
0

There are 0 best solutions below