これは、テキスト編集から単語をコピーし、それをテーブルビューの新しい行に設定する方法です。私が必要としているのは: テキスト編集で選択した単語の色を変更するにはどうすればよいですか? 私のテキスト編集の名前は「editor」です。単語をコピーすると、この単語の色を変更する必要があり、その方法がわかりません。助けてください :)。例をお願いします~~
def addLineTable(self):
row = self.model.rowCount() #create a line into my tableview
self.model.insertRows(row)
column = 0
index = self.model.index(row, column)
tableView = self.TABLE
tableView.setFocus()
tableView.setCurrentIndex(index)
cursor = self.editor.textCursor()
textSelected = cursor.selectedText() #set text to cursor
self.model.setData(index, QVariant(textSelected)) #set text to new tableview line