First of all, I apology for my English. It's not my native language :/

I'm currently trying to learn Qt, and I wanted to do a basic text editor. I would like the user to be able to write, change the color and the font. Everything works fine for the colors, but I have trouble with the fonts. When I change them, all the text in my QTextEdit change. I would like that only the text that is selected changes. And that the text that I write after I changed the font appears with the font I've selected, until I change it again.

I hope you can understand what I mean !

My code for the colors that works :

Qt Code:
  1. void MainWindow::on_pushButton_clicked()
  2. {
  3. ui->textEdit->setTextColor(QColor(QColorDialog().getColor()));
  4. }
To copy to clipboard, switch view to plain text mode 

My code for the fonts that doesn't work :

Qt Code:
  1. void MainWindow::on_pushButton_2_clicked()
  2. {
  3. ui->textEdit->setFont(QFontDialog::getFont(0, ui->textEdit->font()));
  4. }
To copy to clipboard, switch view to plain text mode 

Cordially,
Maxime

I put the text in French :

J'essaie actuellement d'apprendre Qt, et je voulais faire un éditeur de texte basique. J'aimerais que l'utilisateur puisse écrire, changer la couleur et la police. Tout fonctionne bien pour les couleurs, mais j'ai des problèmes avec les polices. Lorsque je les change, tout le texte de mon QTextEdit change. Je voudrais que seul le texte sélectionné soit modifié. Et que le texte que j'écris après avoir changé la police apparaisse avec la police que j'ai sélectionnée, jusqu'à ce que je la change à nouveau.