Don't know why my earlier reply didn't show up...
The clicked() code is like this at the moment.
This launches the dialog, but, I don't know how to get the row data from the delegate button.
def currentIndexChanged(self):
sndr = self.sender()
print("Button Clicked: " + str(sndr.text()))
self.editcuedlg = EditCue(str(sndr.text()))
self.editcuedlg.exec_()
#self.commitData.emit(self.sender())
def currentIndexChanged(self):
sndr = self.sender()
print("Button Clicked: " + str(sndr.text()))
self.editcuedlg = EditCue(str(sndr.text()))
self.editcuedlg.exec_()
#self.commitData.emit(self.sender())
To copy to clipboard, switch view to plain text mode
Regards,
Mac
Added after 42 minutes:
I'm having a hard time getting the big picture of how the model/view/delegate process works...that may be most of my problem. 
In the Qt doc example of delegates it says: "The createEditor() function is called when the user starts editing an item..."
I build the gui with:
if __name__ == '__main__':
ex = Example()
ex.disptext()
sys.exit(app.exec_())
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
ex.disptext()
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
ex.disptext() does this:
def disptext(self):
self.get_table_data()
# set the table model
header = ['','Cue Number', 'Act', 'Scene', 'Page', 'ID', 'Title','Dialog/Prompt']
tablemodel = MyTableModel(self.tabledata, header, self.tv)
self.tv.setModel(tablemodel)
self.tv.resizeColumnsToContents()
for row in range(0, tablemodel.rowCount(tablemodel)):
self.tv.openPersistentEditor(tablemodel.index(row, 0))
def disptext(self):
self.get_table_data()
# set the table model
header = ['','Cue Number', 'Act', 'Scene', 'Page', 'ID', 'Title','Dialog/Prompt']
tablemodel = MyTableModel(self.tabledata, header, self.tv)
self.tv.setModel(tablemodel)
self.tv.resizeColumnsToContents()
for row in range(0, tablemodel.rowCount(tablemodel)):
self.tv.openPersistentEditor(tablemodel.index(row, 0))
To copy to clipboard, switch view to plain text mode
So if if there are 106 rows in the data, createEditor() in the delegate code gets called 106 times, but not later when the user clicks the button delegate.:
class theDelegate(QStyledItemDelegate):
"""
"""
def __init__(self, parent):
# The parent is not an optional argument for the delegate as
# we need to reference it in the paint method (see below)
QStyledItemDelegate.__init__(self, parent)
def createEditor(self, parent, option, index):
editDlg.blockSignals(True)
editDlg.clicked.connect(self.rowButtonClicked)
editDlg.blockSignals(False)
print("createEditor, index = " + str(index.row()))
return editDlg
class theDelegate(QStyledItemDelegate):
"""
"""
def __init__(self, parent):
# The parent is not an optional argument for the delegate as
# we need to reference it in the paint method (see below)
QStyledItemDelegate.__init__(self, parent)
def createEditor(self, parent, option, index):
editDlg = QPushButton("x" + str(index.row()), parent)
editDlg.blockSignals(True)
editDlg.clicked.connect(self.rowButtonClicked)
editDlg.blockSignals(False)
print("createEditor, index = " + str(index.row()))
return editDlg
To copy to clipboard, switch view to plain text mode
Regards,
Mac
Bookmarks