How to set selected text colour, style in Qtableview string

Below is a small working code to diplay what I am trying to achieve.

import sys
import os
import sqlite3

from PyQt5.QtSql import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *


# createDB()
# con_1 = sqlite3.connect("temp.db")

#  # create a table
# con_1.execute('''create table t1(
#    id INTEGER PRIMARY KEY, 'First Name' TEXT, 'Last Name' TEXT, 'Full Name' TEXT);''')

# # populate the table
# con_1.execute("insert into t1 ('First Name', 'Last Name', 'Full Name') values('Wade', 'Wilson', 'Wade Wilson');")
# con_1.execute("insert into t1 ('First Name', 'Last Name', 'Full Name') values('Norman', 'Osborn', 'Norman Osborn');")
# con_1.execute("insert into t1 ('First Name', 'Last Name', 'Full Name') values('Stephen', 'Strange', 'Stephen Strange');")
# con_1.commit()
# con_1.close()

class MultilineTextEditor(QStyledItemDelegate):

    def createEditor(self, parent, options, index):
        return QTextEdit(parent)

    def setEditorData(self, editor, index):
        editor.setText(index.data())

    def setModelData(self, editor, model, index):
        model.setData(index, editor.toPlainText()) 
    
    def paint(self, painter, option, index):
        value = index.data(Qt.DisplayRole)
        if  option.state & QStyle.State_Selected:
            text1 = index.data()
            doc = QTextDocument(text1)
            cursor = QTextCursor(doc)
            cursor.selectedTableCells()
            # cursor.selectedText()  <-- How to impliment this?
            # Trying out to simply select the first line!
            cursor.movePosition(QTextCursor.Start)
            cursor.movePosition(QTextCursor.EndOfLine, QTextCursor.KeepAnchor)
            format = QTextCharFormat()

            format.setFontWeight(QFont.Bold)
            format.setFontPointSize(20)
            weight = QFont.DemiBold
            format.setFontWeight(weight)
            cursor.mergeCharFormat(format)
            print(cursor.selectedText())
            # painter commands??        
            QStyledItemDelegate.paint(self, painter, option, index)
        else:
            QStyledItemDelegate.paint(self, painter, option, index)
            
class TableViewer(QMainWindow):
    def __init__(self):
        super().__init__()
        working_dir = os.getcwd()
        db_path = f"{working_dir}\temp.db"
        print(db_path)
        self.db = QSqlDatabase.addDatabase("QSQLITE")
        self.db.setDatabaseName(db_path)

        self.db.open()

        self.model = QSqlTableModel(self, self.db)   
        self.model.setTable('t1')
        self.model.select()

        self.tableView = QTableView(self)
        self.tableView.setModel(self.model)
        self.tableView.resizeColumnsToContents()
        layout = QVBoxLayout()
        layout.addWidget(self.tableView)
        
        widget = QWidget()
        widget.setLayout(layout)
        self.setCentralWidget(widget)

        self.tableView.setItemDelegateForColumn(2, MultilineTextEditor())
        self.show()

if __name__ == '__main__':
    app = QApplication(sys.argv)
    tv = TableViewer()
    sys.exit(app.exec_())
  1. A SQL Lite Database (temp.db) is created in the commented out sections
  2. This db is read and displayed as in Qtableview
  3. The column containing full names is editable

How would you set the format (bold, Italics, underline), size or colour of selcted string? I would eventually bind the selection with say keyboard shorcuts (eg cntr + B for bold) or display a toolbar for user selection. Found an example here: https://forum.qt.io/topic/138318/how-do-you-bold-and-un-bold-a-selected-text-pyqt-or-pyside. But Im unable to implement it, even rudementarily in Qtableview cell.
The rich text data should be saved back to be retrieved from the DB. Unfortunately I am unable to find any good explainitions on Delgate –> paint.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật