-1
def add_question(self):
    sub_id = self.qSubComboBox.itemData(self.qComboBox.currentIndex())
    question = self.textEdit.toPlainText()
    option1 = self.textEdit_2.toPlainText()
    option2 = self.textEdit_3.toPlainText()
    option3 = self.textEdit_4.toPlainText()
    option4 = self.textEdit_5.toPlainText()
    option5 = self.textEdit_6.toPlainText()
    data = (sub_id,question,option1,option2,option3,option4,option5,)

    if question=="" or option1=="" or option2=="":
        QMessageBox.about(self, "Uyarı", "Soru metni ve en az iki seçenek boş bırakılamaz.")
    else:
        helper.insert("INSERT INTO question(SubID,Question,Option1,Option2,Option3,Option4,Option5) VALUES(?,?,?,?,?,?,?)", data)
        QMessageBox.about(self, "TestPro", "Soru başarıyla kaydedildi.")

'''I want to save QTextEdit contents to database with text formatting.'''

  • If you want to preserve rich text then try `QTextEdit.toHtml()` instead of `QTextEdit.toPlainText()` – alec Feb 19 '20 at 09:16
  • I tried toHtml function before.It is work but it is adding a lot of html tags to database.İs there another way? – Emrah şahan Feb 19 '20 at 10:31

1 Answers1

0

Example : test text is bold >> tohmtl() . When I saved to database,

My database record is: <----html>.... .....test ....<---html>

is there a another simply way:)?