Hi,
I have mainWindow in that one addButton that will create newWidget and add it to mainWindow(addButton can be pressed multiple times and every time it will create newWidget and add it to mainWindow). For that i have kept separate object for newWidget so every time button get clicked it will call that object. and for that i have one default dictionary for this newWidget that will get added the main dictionary.
My problem is, if there is multiple widget, i am not able to figure out which widget got deleted. if that gets deleted i want to remove it from my dictionary too.
so how can i get which Widget got deleted, because in mainWindow there are multiple newWidgets.
what i was thinking that if i can get name of the groupBox (from below code), in my mainWindow class i will be able to remove it from dictionary,
I could have done the closing connection part in my mainWindow class but by doing that if multiple newWidgets in my new window and if close very fist newWidget it always closing very last newWidget created.
i dont know how .emit work if i can get value from this class to my mainWindow class
My this is the code of newWidget:-
class controlShapes(controlShapesUI.Ui_controlShapes, QtWidgets.QWidget):
def __init__(self, parentWin):
super(controlShapes, self).__init__(parentWin)
self.setupUi(self)
self.LE_shapesToExport.setText("*ctrl")
self.LE_csFilePath.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.LE_csFilePath.customContextMenuRequested.connect(self.CM_LE_csFilePath)
self.LE_shapesToExport.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.LE_shapesToExport.customContextMenuRequested.connect(self.CM_LE_shapesToExport)
self.menu = QtWidgets.QMenu()
self.A_delete = self.menu.addAction("Delete")
self.A_moveUp = self.menu.addAction("Move Up")
self.A_moveDown = self.menu.addAction("Move Down")
self.B_options.setMenu(self.menu)
self.B_options.setStyleSheet('QPushButton::menu-indicator { image: none; width: 0px; }')
def closeControlShapesUI(self):
groupBoxName = self.B_options.parent().title()
# print groupBoxName
# self.A_delete.emit(QtCore.SIGNAL("GB_Name"), groupBoxName)
self.close()
return groupBoxName
def CM_LE_shapesToExport(self):
menu = self.LE_shapesToExport.createStandardContextMenu()
self.A_selectCS = menu.addAction("Select Controllers", self.selectControllers)
separator = menu.addSeparator()
menu.insertActions(menu.actions()[0], [self.A_selectCS, separator])
menu.exec_(QtGui.QCursor.pos())
def CM_LE_csFilePath(self):
menu = self.LE_csFilePath.createStandardContextMenu()
A_exportCS = menu.addAction("Export Control Shapes")
A_releaseCS = menu.addAction("Release Control Shapes")
separator = menu.addSeparator()
menu.insertActions(menu.actions()[0], [A_exportCS, A_releaseCS, separator])
menu.exec_(QtGui.QCursor.pos())
def selectControllers(self):
print "selected"
Thanks in advance,
Soham.